node-dev icon indicating copy to clipboard operation
node-dev copied to clipboard

adding file extensions for watch

Open staminna opened this issue 9 years ago • 2 comments

Hi

I am trying to add twig.js files (.twig) into the node-dev watch file system changes like

{ "notify": true, "clearScreen": true, "timestamp": true, "vm": false, "extensions": { "ls": "LiveScript", "ts": "typescript", "coffee": "coffee-script", "twig": "twig.js" } }

It accepts the entry with no error, but it doesn't seem to detect when I change the file.

staminna avatar Feb 02 '16 16:02 staminna

node-dev only watches files that have been require()'d. It does not scan the whole directory tree (which it would have to do in order to watch arbitrary files). For that use case http://nodemon.io/ has you covered.

You could also use the following code in order to tell node-dev to watch certain files, but I would not really recommend that kind of coupling:

process.send({cmd: 'NODE_DEV', required: '/path/to/template.twig'})

BTW, the extensions configuration option is there to allow transpilers to hook into the module system, like https://babeljs.io/docs/usage/require/

fgnass avatar Feb 02 '16 17:02 fgnass

@fgnass why do you not recommend that kind of coupling? It seems really useful to have file watching and process restarting handled by one thing that is extensible by the end-user or other modules. Nested watchers/restarters doesn't seem like a good idea and it's nice to have a centralized thing deal with things like notifications.

parshap avatar Feb 03 '16 04:02 parshap