Skip to content

Commit

Permalink
add breaking test for package.scripts.start overruling nodemon.json
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn committed Dec 4, 2014
1 parent 68c8b17 commit 3749125
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/config/load.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
/*global describe:true, it: true, afterEach: true, beforeEach: true, after:true */
var load = require('../../lib/config/load'),
cli = require('../../lib/cli/'),
path = require('path'),
testUtils = require('../utils'),
utils = require('../../lib/utils'),
Expand All @@ -10,6 +11,16 @@ var load = require('../../lib/config/load'),
command = require('../../lib/config/command'),
assert = require('assert');

function asCLI(cmd) {
return ('node nodemon ' + (cmd|| '')).trim();
}

function parse(cmd) {
var parsed = cli.parse(cmd);
parsed.execOptions = exec(parsed);
return parsed;
}

function commandToString(command) {
return command.executable + (command.args.length ? ' ' + command.args.join(' ') : '');
}
Expand Down Expand Up @@ -126,6 +137,17 @@ describe('config load', function () {
});
});

it('should give user specified exec preference of package.scripts.start', function (done) {
process.chdir(path.resolve(pwd, 'test/fixtures/packages/start-and-settings'));
var config = {},
settings = parse(asCLI()),
options = {};
load(settings, options, config, function (config) {
assert.deepEqual(config.exec, 'foo', 'exec is "foo": ' + config.exec);
done();
});
});

it('should support "ext" with "execMap"', function (done) {
// prevents our test from finding the nodemon.json files
process.chdir(path.resolve(pwd, 'test/fixtures/legacy'));
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/packages/start-and-settings/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"exec": "foo"
}
5 changes: 5 additions & 0 deletions test/fixtures/packages/start-and-settings/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"start": "node app.js"
}
}

0 comments on commit 3749125

Please sign in to comment.