mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
This was copied and pasted more than a handful of times around the library and tests. Some implementations were more naive and did not try to add quotes if there are spaces within a single argument. There is one slight oddity in one of the cli parse tests. Stringifying the command causes many of the arguments to show up in quotes when they probably shouldn't. This seems to trace back to a deep problem related to how commands are pulled out of package.scripts.start and is out of scope for this patch. Even though the test might look incorrect now, it is an accurate reflection of what the generated command is.
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
'use strict';
|
|
/*global describe:true, it: true */
|
|
var stringify = require('../../lib/utils').stringify,
|
|
assert = require('assert');
|
|
|
|
describe('stringify', function () {
|
|
it('should combine the executable and arguments', function () {
|
|
var string = stringify('node', ['./app.js', '--flag']);
|
|
var expected = 'node ./app.js --flag';
|
|
|
|
assert(string === expected, "stringified to " + string);
|
|
});
|
|
it('should not include excess whitespace', function () {
|
|
var string = stringify('node');
|
|
var expected = 'node';
|
|
|
|
assert(string === expected, "stringified to " + string);
|
|
});
|
|
it('should quote arguments with spaces', function () {
|
|
var string = stringify('node', ['./app.js', '--one --two']);
|
|
var expected = 'node ./app.js "--one --two"';
|
|
|
|
assert(string === expected, "stringified to " + string);
|
|
});
|
|
it('should escape quotes', function () {
|
|
var string = stringify('node', ['./app.js', '--one "--two --three"']);
|
|
var expected = 'node ./app.js "--one \\"--two --three\\""';
|
|
|
|
assert(string === expected, "stringified to " + string);
|
|
});
|
|
});
|