Files
archived-nodemon/test/cli/exec.test.js
2013-12-11 15:16:32 +00:00

87 lines
3.1 KiB
JavaScript

'use strict';
/*global describe:true, it: true */
var exec = require('../../lib/config/exec'),
run = require('../../lib/monitor/run'),
assert = require('assert');
describe('nodemon exec', function () {
it('should default to node', function () {
var options = exec({ script: 'index.js' });
assert(options.exec === 'node');
assert(options.ext === '.js$');
});
it('should support --debug', function () {
var options = exec({ script: 'app.js', nodeArgs: [ '--debug' ]});
assert(options.exec === 'node');
assert(options.execArgs.indexOf('--debug') !== -1);
assert(options.ext.indexOf('.js') !== -1);
});
it('should support --debug=XXXX', function () {
var options = exec({ script: 'app.js', nodeArgs: [ '--debug=9999' ]});
assert(options.exec === 'node');
assert(options.execArgs.indexOf('--debug=9999') !== -1);
assert(options.ext.indexOf('.js') !== -1);
});
it('should support multiple extensions', function () {
var options = exec({ script: 'app.js', ext: 'js, jade, hbs' });
assert(options.exec === 'node');
assert(options.ext.indexOf('jade') !== -1, 'comma separated string');
options = exec({ script: 'app.js', ext: 'js|jade|hbs' });
assert(options.exec === 'node');
assert(options.ext.indexOf('jade') !== -1, 'pipe separated string');
});
it('should replace {{filename}}', function () {
var options = exec({ script: 'app.js', exec: 'node {{filename}}.tmp --somethingElse' });
var command = run.command({ execOptions: options });
assert(command.executable + ' ' + command.args.join(' ') === 'node app.js.tmp --somethingElse', 'filename is interpolated');
});
it('should support extension maps', function () {
var options = exec({ script: 'template.jade' }, { 'jade': 'jade {{filename}} --out /tmp' });
assert(options.exec === 'jade', 'correct exec is used');
assert(options.execArgs[0] === 'template.jade', 'filename interpolated');
});
it('should support input from argv#parse', function () {
var parse = require('../../lib/cli/parse');
parse('node /usr/local/bin/nodemon.js --debug -e js,jade,hbs app.js'.split(' '));
});
it('should use coffeescript on .coffee', function () {
var options = exec({ script: 'index.coffee' });
assert(options.exec === 'coffee');
assert(options.ext.indexOf('.coffee') !== -1);
});
it('should support coffeescript in debug mode', function () {
var options = exec({ script: 'app.coffee', nodeArgs: [ '--debug' ] });
assert(options.exec === 'coffee');
assert(options.execArgs.indexOf('--debug') !== -1);
assert(options.ext.indexOf('.coffee') !== -1);
});
it('should support custom execs', function () {
var options = exec({ script: 'app.py', exec: 'python'});
assert(options.exec === 'python');
assert(options.ext.indexOf('.py') !== -1);
});
it('should support custom executables with arguments', function () {
var options = exec({ script: 'app.py', exec: 'python --debug'});
assert(options.exec === 'python');
assert(options.execArgs.indexOf('--debug') !== -1);
assert(options.ext.indexOf('.py') !== -1);
});
});