Skip to content

Commit

Permalink
fix: {{filename}} is only replaced once
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-perez authored and remy committed May 5, 2018
1 parent 97f8d0a commit f616258
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/config/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '';
});
Expand Down
6 changes: 6 additions & 0 deletions test/cli/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit f616258

Please sign in to comment.