Skip to content

Commit f616258

Browse files
victor-perezremy
authored andcommitted
fix: {{filename}} is only replaced once
1 parent 97f8d0a commit f616258

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/config/exec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function execFromPackage() {
3333
}
3434

3535
function replace(map, str) {
36-
var re = new RegExp('{{(' + Object.keys(map).join('|') + ')}}');
36+
var re = new RegExp('{{(' + Object.keys(map).join('|') + ')}}', 'g');
3737
return str.replace(re, function (all, m) {
3838
return map[m] || all || '';
3939
});

test/cli/parse.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ describe('nodemon CLI parser', function () {
5151
assert(cmd === 'node test/fixtures/app.js.tmp --somethingElse', cmd);
5252
});
5353

54+
it('should replace {{filename}} multiple times', function () {
55+
var settings = parse(asCLI('test/fixtures/app.js --exec "node {{filename}}.tmp {{filename}}.tmp" --somethingElse'));
56+
var cmd = commandToString(command(settings));
57+
assert(cmd === 'node test/fixtures/app.js.tmp test/fixtures/app.js.tmp --somethingElse', cmd);
58+
});
59+
5460
it('should parse the help examples #1', function () {
5561
var settings = parse(asCLI('test/fixtures/app.js')),
5662
cmd = commandToString(command(settings));

0 commit comments

Comments
 (0)