Handle exit codes from npm install with the create command.
This commit is contained in:
parent
5ea787b3a1
commit
7e174fd0cd
@ -150,8 +150,11 @@ function create(options, done) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
npm.on('close', function (code) {
|
npm.on('close', function (code) {
|
||||||
//todo: handle code
|
if (code !== 0) {
|
||||||
next();
|
return next(new Error('There was an error installing dependencies.'));
|
||||||
|
} else {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ var create = proxyquire('../../lib/scaffold/create', {
|
|||||||
on: sinon.stub()
|
on: sinon.stub()
|
||||||
},
|
},
|
||||||
on: function(event, cb) {
|
on: function(event, cb) {
|
||||||
cb();
|
cb(0);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -134,10 +134,6 @@ describe('#create', function() {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
var packagePath = testDir + '/mynode3/package.json';
|
var packagePath = testDir + '/mynode3/package.json';
|
||||||
should.equal(fs.existsSync(packagePath), false);
|
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.');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user