Skip to content

Commit e6708d2

Browse files
committed
Merge pull request #693 from pensierinmusica/patch-1
fix: JSON extension not watched outside of coffeescript
2 parents 2f19ffb + ceb1515 commit e6708d2

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

lib/config/exec.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,9 @@ function exec(nodemonOptions, execMap) {
7373
var options = utils.clone(nodemonOptions || {});
7474
var script = path.basename(options.script || '');
7575
var scriptExt = path.extname(script).slice(1);
76-
var extension = options.ext || scriptExt || 'js';
76+
var extension = options.ext || scriptExt || 'js,json';
7777
var execDefined = !!options.exec;
7878

79-
// strip any leading periods int he extension
80-
if (extension.indexOf('.') === 0) {
81-
extension = extension.slice(1);
82-
}
83-
8479
// allows the user to simplify cli usage:
8580
// https://github.com/remy/nodemon/issues/195
8681
// but always give preference to the user defined argument
@@ -146,7 +141,7 @@ function exec(nodemonOptions, execMap) {
146141
if (options.exec === 'coffee') {
147142
// don't override user specified extension tracking
148143
if (!options.ext) {
149-
extension = 'coffee litcoffee js json';
144+
extension = 'coffee,litcoffee,js,json';
150145
}
151146

152147
// because windows can't find 'coffee', it needs the real file 'coffee.cmd'
@@ -156,22 +151,11 @@ function exec(nodemonOptions, execMap) {
156151
}
157152

158153
// allow users to make a mistake on the extension to monitor
159-
// converts js,jade => js,jade
160-
// and 'js jade' => js,jade
154+
// converts .js, jade => js,jade
161155
// BIG NOTE: user can't do this: nodemon -e *.js
162156
// because the terminal will automatically expand the glob against
163157
// the file system :(
164-
if (extension.indexOf(' ') !== -1 ||
165-
extension.indexOf(',') !== -1 ||
166-
extension.indexOf('*.') !== -1) {
167-
168-
extension = extension.replace(/\s+/g, '|') // convert spaces to pipes
169-
.replace(/,/g, '|') // convert commas to pipes
170-
.split('|') // split on those pipes
171-
.map(function (item) {
172-
return item.replace(/^[\*\.]+/, ''); // remove "*."
173-
}).join(','); // return regexp string like: js,jade
174-
}
158+
extension = extension.match(/\w+/g).join(',');
175159

176160
options.ext = extension;
177161

0 commit comments

Comments
 (0)