Handle exit codes from npm install with the create command.

This commit is contained in:
Braydon Fuller 2015-08-25 13:15:30 -04:00
parent 5ea787b3a1
commit 7e174fd0cd
2 changed files with 36 additions and 7 deletions

View File

@ -150,8 +150,11 @@ function create(options, done) {
});
npm.on('close', function (code) {
//todo: handle code
next();
if (code !== 0) {
return next(new Error('There was an error installing dependencies.'));
} else {
return next();
}
});
} else {

View File

@ -13,7 +13,7 @@ var create = proxyquire('../../lib/scaffold/create', {
on: sinon.stub()
},
on: function(event, cb) {
cb();
cb(0);
}
})
}
@ -134,10 +134,6 @@ describe('#create', function() {
throw err;
}
if (err) {
throw err;
}
var packagePath = testDir + '/mynode3/package.json';
should.equal(fs.existsSync(packagePath), false);
@ -145,4 +141,34 @@ describe('#create', function() {
});
it('will receieve an error from npm', function() {
var createtest = proxyquire('../../lib/scaffold/create', {
'child_process': {
spawn: sinon.stub().returns({
stdout: {
on: sinon.stub()
},
stderr: {
on: sinon.stub()
},
on: function(event, cb) {
cb(1);
}
})
}
});
createtest({
cwd: testDir,
dirname: 'mynode4',
name: 'My Node 4',
isGlobal: false,
datadir: '../.bitcoin'
}, function(err) {
should.exist(err);
err.message.should.equal('There was an error installing dependencies.');
});
});
});