diff --git a/lib/config/exec.js b/lib/config/exec.js index 65ec7bdb..951ac7a1 100644 --- a/lib/config/exec.js +++ b/lib/config/exec.js @@ -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 || ''; }); diff --git a/test/cli/parse.test.js b/test/cli/parse.test.js index 636feb5f..77cc83de 100644 --- a/test/cli/parse.test.js +++ b/test/cli/parse.test.js @@ -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));