Add test to check if passed opts are priority

Currently failing due to bug in code - THIS IS MY PLAN!
This commit is contained in:
Remy Sharp
2015-01-20 14:08:11 +00:00
parent 44f7d49f86
commit 51f825d341
4 changed files with 31 additions and 2 deletions

View File

@@ -96,6 +96,7 @@ function run(options) {
utils.log.detail('child pid: ' + child.pid);
child.on('error', function (error) {
bus.emit('error', error);
if (error.code === 'ENOENT') {
utils.log.error('unable to run executable: "' + cmd.executable + '"');
process.exit(1);
@@ -106,9 +107,16 @@ function run(options) {
});
child.on('exit', function (code, signal) {
if (code === 127) {
utils.log.error('failed to start process, "' + cmd.executable + '" exec not found');
bus.emit('error', code);
process.exit();
}
if (code === 2) {
// something wrong with parsed command
utils.log.error('failed to start process, possible issue with exec arguments');
bus.emit('error', code);
process.exit();
}

View File

@@ -36,7 +36,7 @@
"scripts": {
"coverage": "istanbul cover _mocha -- --timeout 30000 --ui bdd --reporter list test/**/*.test.js",
":test": "node_modules/.bin/mocha --timeout 30000 --ui bdd test/**/*.test.js",
"test": "for FILE in `ls test | egrep -v 'fixtures|mocha.opts|utils.js'`; do echo test/$FILE; ./node_modules/.bin/mocha --timeout 30000 test/$FILE; if [ $? -ne 0 ]; then exit 1; fi; sleep 1; done",
"test": "for FILE in test/**/*.test.js; do echo $FILE; ./node_modules/.bin/mocha --timeout 30000 $FILE; if [ $? -ne 0 ]; then exit 1; fi; sleep 1; done",
"web": "node web"
},
"devDependencies": {

View File

@@ -0,0 +1 @@
{ "scripts": { "start": "foo" } }

View File

@@ -5,7 +5,8 @@ var nodemon = require('../../lib/'),
path = require('path'),
touch = require('touch'),
utils = require('../utils'),
appjs = path.resolve(__dirname, '..', 'fixtures', 'app.js');
appjs = path.resolve(__dirname, '..', 'fixtures', 'app.js'),
envjs = path.resolve(__dirname, '..', 'fixtures', 'env.js');
describe('require-able', function () {
var pwd = process.cwd(),
@@ -24,6 +25,25 @@ describe('require-able', function () {
nodemon.reset(done);
});
it('should prioritise options over package.start', function (done) {
process.chdir(path.resolve('fixtures/packages/start-ignored'));
nodemon({
script: envjs,
env: { USER: 'nodemon' },
stdout: false,
verbose: false,
// }).on('log', function (event) {
// console.log(event.colour);
}).on('stdout', function (data) {
var out = data.toString().trim();
assert(out === 'nodemon', 'expected output: ' + out);
done();
}).on('error', function (e) {
assert(false, 'script did not run: ' + e);
done();
});
});
it('should know nodemon has been required', function () {
assert(nodemon.config.required, 'nodemon has required property');