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(
|
||||
services,
|
||||
function(service, next) {
|
||||
|
@ -95,12 +97,18 @@ function add(options, done) {
|
|||
return next(err);
|
||||
}
|
||||
|
||||
// TODO: get the name of the package from the updated package.json
|
||||
// to be able to support other types of installation such as
|
||||
// hosted git urls
|
||||
// get the name of the service from package.json
|
||||
var updatedPackage = JSON.parse(fs.readFileSync(packagePath));
|
||||
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
|
||||
addConfig(bitcoreConfigPath, service, next);
|
||||
addConfig(bitcoreConfigPath, serviceName, next);
|
||||
});
|
||||
}, done
|
||||
);
|
||||
|
|
|
@ -91,6 +91,13 @@ describe('#add', function() {
|
|||
});
|
||||
|
||||
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({
|
||||
stdout: {
|
||||
on: sinon.stub()
|
||||
|
@ -103,6 +110,19 @@ describe('#add', function() {
|
|||
var addtest = proxyquire('../../lib/scaffold/add', {
|
||||
'child_process': {
|
||||
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({
|
||||
|
|
Loading…
Reference in New Issue