Merge pull request #227 from braydonf/add-cmd-remote
Bitcore Node Add Command with Remote URLS
This commit is contained in:
commit
aa9504a402
@ -86,6 +86,8 @@ function add(options, done) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldPackage = JSON.parse(fs.readFileSync(packagePath));
|
||||||
|
|
||||||
async.eachSeries(
|
async.eachSeries(
|
||||||
services,
|
services,
|
||||||
function(service, next) {
|
function(service, next) {
|
||||||
@ -95,12 +97,18 @@ function add(options, done) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: get the name of the package from the updated package.json
|
// get the name of the service from package.json
|
||||||
// to be able to support other types of installation such as
|
var updatedPackage = JSON.parse(fs.readFileSync(packagePath));
|
||||||
// hosted git urls
|
var newDependencies = _.difference(
|
||||||
|
Object.keys(updatedPackage.dependencies),
|
||||||
|
Object.keys(oldPackage.dependencies)
|
||||||
|
);
|
||||||
|
$.checkState(newDependencies.length === 1);
|
||||||
|
oldPackage = updatedPackage;
|
||||||
|
var serviceName = newDependencies[0];
|
||||||
|
|
||||||
// add service to bitcore-node.json
|
// add service to bitcore-node.json
|
||||||
addConfig(bitcoreConfigPath, service, next);
|
addConfig(bitcoreConfigPath, serviceName, next);
|
||||||
});
|
});
|
||||||
}, done
|
}, done
|
||||||
);
|
);
|
||||||
|
|||||||
@ -91,6 +91,13 @@ describe('#add', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('will update bitcore-node.json services', function(done) {
|
it('will update bitcore-node.json services', function(done) {
|
||||||
|
var callCount = 0;
|
||||||
|
var oldPackage = {
|
||||||
|
dependencies: {
|
||||||
|
'bitcore': '^v0.13.1',
|
||||||
|
'bitcore-node': '^v0.2.0'
|
||||||
|
}
|
||||||
|
};
|
||||||
var spawn = sinon.stub().returns({
|
var spawn = sinon.stub().returns({
|
||||||
stdout: {
|
stdout: {
|
||||||
on: sinon.stub()
|
on: sinon.stub()
|
||||||
@ -103,6 +110,19 @@ describe('#add', function() {
|
|||||||
var addtest = proxyquire('../../lib/scaffold/add', {
|
var addtest = proxyquire('../../lib/scaffold/add', {
|
||||||
'child_process': {
|
'child_process': {
|
||||||
spawn: spawn
|
spawn: spawn
|
||||||
|
},
|
||||||
|
'fs': {
|
||||||
|
readFileSync: function() {
|
||||||
|
if (callCount === 1){
|
||||||
|
oldPackage.dependencies.a = '^v0.1';
|
||||||
|
} else if (callCount === 2){
|
||||||
|
oldPackage.dependencies.b = '^v0.1';
|
||||||
|
} else if (callCount === 3){
|
||||||
|
oldPackage.dependencies.c = '^v0.1';
|
||||||
|
}
|
||||||
|
callCount++;
|
||||||
|
return JSON.stringify(oldPackage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addtest({
|
addtest({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user