fix: {{filename}} is only replaced once

This commit is contained in:
Victor Perez
2018-05-04 14:47:35 +02:00
committed by Remy Sharp
parent 97f8d0a175
commit f616258669
2 changed files with 7 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ function execFromPackage() {
}
function replace(map, str) {
var re = new RegExp('{{(' + Object.keys(map).join('|') + ')}}');
var re = new RegExp('{{(' + Object.keys(map).join('|') + ')}}', 'g');
return str.replace(re, function (all, m) {
return map[m] || all || '';
});

View File

@@ -51,6 +51,12 @@ describe('nodemon CLI parser', function () {
assert(cmd === 'node test/fixtures/app.js.tmp --somethingElse', cmd);
});
it('should replace {{filename}} multiple times', function () {
var settings = parse(asCLI('test/fixtures/app.js --exec "node {{filename}}.tmp {{filename}}.tmp" --somethingElse'));
var cmd = commandToString(command(settings));
assert(cmd === 'node test/fixtures/app.js.tmp test/fixtures/app.js.tmp --somethingElse', cmd);
});
it('should parse the help examples #1', function () {
var settings = parse(asCLI('test/fixtures/app.js')),
cmd = commandToString(command(settings));