Git Product home page Git Product logo

npm-watch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

npm-watch's Issues

Quiet [nodemon]

It is possible to hide [taskname] prefix with quiet: true. Is it possible to hide rows that have [nodemon]?

Not watching *html files with valid template

I run npm-watch in whole project directory with pattern

  "watch": {
    "push": "*.{js,html}"
  },

It works only when saving *.js files

My file tree:
└─ main.js
└─ variables-dialog.html
└─ variables-service.js
└─ package.json
└─ package-lock.json

color output

Is there a way to "inherit" the output of the processes so the color is preserved?

I did this locally and it works, but I'm assuming that'd break something. (didn't test any further since it works for me)

    // Line:76 watch-package.js
    var proc = processes[script] = spawn(nodemon, args, {
      env: process.env,
      cwd: pkgDir,
      stdio: 'inherit',
    })
    return;
    if (quiet === true || quiet === 'true') {
    ...

chokidar instead of nodemon?

It's what gulp uses. One benefit that I've noticed is that it continues to watch even after my workstation has woken from sleep.

Edit: It just occurred to me that chokidar would not restart the process.

Does not work with patterns (macOS)

There's a similar issue but in my case npm-watch actually works as long as the concrete file is specified, e.g.:

{
  watch: {
    compile: [
      'dir/file.js'
    ]
  }
}

As soon as I replace it with a pattern, e.g. dir/*.js, nothing gets restarted.

Unrecognized input: rs

To restart npm-watch I tried to input nodemon's "rs", but it is not recognized:

[nodemon] starting `npm.cmd run -s build:client`
[nodemon] clean exit - waiting for changes before restart
rs
Unrecognized input: rs

Corresponding watch entry is:

    "build:client": {
      "patterns": [
        "client"
      ],
      "extensions": "ts",
      "delay": 1000
    },

Is there a way to restart watch without resorting to kill everything and relaunch?
Thanks for clarifying!
mario

Enhancement - runOnStartupOnly

npm-watch has the neat effect of running scripts in parallel and a runOnStartupOnly option might be useful to tell npm-watch to run a batch of scripts once and then terminate (like npm-run-all).

MaxListenersExceededWarning when running many watches

I run a handful of watches and I get these warnings:

(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unpipe listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 finish listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unpipe listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit
(node:15779) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 finish listeners added. Use emitter.setMaxListeners() to increase limit

When this happens, it doesn't seem to detect changes to files. It's possible this is actually a nodemon issue.

send kill signal to previous started process

currently, my watch command slowly eats memory as it triggers more and more processes. Is there a way to send a kill to previously started process ahead of starting a new one?

More maintainers

Since I'm not really keeping on top of my GH issues these days, I've added @moos and @jackwanders as maintainers of this module on npm and collaborators here on Github. They've both made good contributions and I see no reason they shouldn't be able to publish those themselves 😄

Changes aren't triggering watcher

I'm on node 7.2.1. After the initial commands are run, nothing seems to be setting it off again. Anyone else seeing this issue? Could be an issue with nodemon?

npm-watch
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /Users/kevincolten/github/austincodingacademy.github.io/_images/**/*
[nodemon] starting `npm run images`
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: sass
[nodemon] starting `npm run sass`
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /Users/kevincolten/github/austincodingacademy.github.io/_javascripts/**/*
[nodemon] starting `npm run js`

> [email protected] images /Users/kevincolten/github/austincodingacademy.github.io
> imagemin _images/* --out-dir=assets/images


> [email protected] js /Users/kevincolten/github/austincodingacademy.github.io
> mkdir -p assets/javascripts && browserify _javascripts/app.js | uglifyjs -c > assets/javascripts/app.js


> [email protected] sass /Users/kevincolten/github/austincodingacademy.github.io
> node-sass --output-style compressed -o assets/stylesheets/ _sass/app.scss --source-map=true

[nodemon] clean exit - waiting for changes before restart
34 images minified
[nodemon] clean exit - waiting for changes before restart
[nodemon] clean exit - waiting for changes before restart

Here's the relevant part of my package.json

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "sass": "node-sass --output-style compressed -o assets/stylesheets/ _sass/app.scss --source-map=true",
    "js": "mkdir -p assets/javascripts && browserify _javascripts/app.js | uglifyjs -c > assets/javascripts/app.js",
    "images": "imagemin _images/* --out-dir=assets/images",
    "build": "npm run sass && npm run js && npm run images",
    "postinstall": "jekyll build && npm run build",
    "watch": "npm-watch"
  },
  "watch": {
    "sass": {
      "patterns": ["sass"],
      "extensions": "scss",
      "inherit": true
    },
    "js": {
      "patterns": ["_javascripts"],
      "extensions": "js",
      "inherit": true
    },
    "images": {
      "patterns": ["_images"],
      "extensions": "jpg,jpeg,png,tiff,gif,svg",
      "inherit": true
    }
  },

add test suite

To implement such, we'll need some kind of callback for the tests to wait for before checking that changes were made. Doing so with child_process is complicated and not ideal. Is there a reason to not use nodemon's programmatic API?

Forgot parameters inherits in the documentation

I looked for keeping color in command line, but I never found a possibility in your documentation until I analyze the source code.

Please can you add "inherit:true" in your example in your documentation, and comment a little the example ?

npm-watch is great and simple, long life to npm-watch.

Lacking ability to watch non-default file extensions

By default, nodemon only watches .js, .coffee, and .litcoffee files.

It is not uncommon to have npm scripts that act on non JavaScript files, for example:

"scripts": {
  "less": "lessc src/styles/stylesheet.less dist/styles/stylesheet.css"
},
"watch": {
  "less": "src/styles"
}

Any attempt to use npm-watch to re-run this script when the .less file changes will fail. The nodemon command that npm-watch generates is

nodemon --watch src/styles --exec npm run less

When the requried command is

nodemon --ext less --watch src/styles --exec npm run less

It would be great if npm-watch could optionally accept an object as the value for a given key, such as:

"watch": {
  "less": {
    "files": "src/styles",
    "ext": "less"
  }
}

I would be happy to provide a pull request to implement this functionality, but I wanted to float this by you and get buy-in; at the moment it doesn't appear that this package is being actively maintained.

Empty tags

When I have a <script src="my-script.js"></script> the tag is converted to <script src="my-script.js"/> and the browser can't render the entire HTML file.
The same with <div data-attr="my value"></div>.

There's some config or something that I can do rather than <script src="my-script.js">return;</script> or <div data-attr="my value">&nbsp;</div>?

How to ignore certain files?

I wanted to watch only the js files and call the script lint on any change. So for that I had written:

"watch": {
    "lint": "*.js"
  },
"scripts": {
    "lint": "chmod +x script.sh | ./script.sh",
    "lint-watch": "npm-watch"
  }

Now I wish to ignore certain folder, how shall I do so?

"watch": {
    "lint": {
          "ignore": "foldername/*.js"
    }
  },

Writing the above lines does not work .
Also, What is the pattern key for?

Running script multiple times

"scripts" : {
  "lint": "lint-staged",
  "lint-watch": "npm-watch"
},
"lint-staged": {
    "*.js": "eslint"
  },
"watch": {
   "lint": {
      "patterns": "*",
      "extensions": "js",
      "ignore": "node_modules"
   }
},

I have the above code written in package.json. When I run npm run lint-watch, it runs npm run lint three times each time.
I get the following output:

Sterics-MacBook-Pro:$ npm run lint-watch

>lint-watch /Users
> npm-watch

No task specified. Will go through all possible tasks
[lint] [nodemon] 1.11.0
[lint] [lint] [17:06:15] Running tasks for *.js [started]
[lint] [17:06:15] eslint [started]
[lint] [17:06:18] eslint [failed]
[lint] [17:06:18] → 🚫 eslint found some errors. Please fix them and try committing again.

/Users/tools/static.js
  36:19  error  Unexpected parentheses around single function argument  arrow-parens
  56:21  error  Unexpected parentheses around single function argument  arrow-parens
  58:19  error  Unexpected parentheses around single function argument  arrow-parens

✖ 3 problems (3 errors, 0 warnings)



[lint] [17:06:18] Running tasks for *.js [failed]
[lint] [17:06:18] → 🚫 eslint found some errors. Please fix them and try committing again.

/Users/tools/static.js
  36:19  error  Unexpected parentheses around single function argument  arrow-parens
  56:21  error  Unexpected parentheses around single function argument  arrow-parens
  58:19  error  Unexpected parentheses around single function argument  arrow-parens

✖ 3 problems (3 errors, 0 warnings)



[lint] [lint] 🚫 eslint found some errors. Please fix them and try committing again.

/Users/tools/static.js
  36:19  error  Unexpected parentheses around single function argument  arrow-parens
  56:21  error  Unexpected parentheses around single function argument  arrow-parens
  58:19  error  Unexpected parentheses around single function argument  arrow-parens

✖ 3 problems (3 errors, 0 warnings)



[lint] [lint] [nodemon] app crashed - waiting for file changes before starting...

Why is this happening?

Can't attach debugger

Hi,
I find impossible to configure node.js debugger with npm-watch. Could you please add that feature?

triggered only when new files are creaeted not on modify

I'm on linux, and this does't work, It's only triggered when new files are created but not when existing files change. tried both with

"watch": {
    "build": "src/*.ts"
  },

and with

"watch": {
    "build": {
      "patterns": ["src"],
      "extensions": "ts",
      "quiet": false,
      "legacyWatch": true,
      "runOnChangeOnly": false
    }
  },

Note that in the readme with cat you are always replacing the file because you use > and not mofifying it (that would be using >>...

npm-watch fails with ENOENT, unhandled error event

C:\project>npm-watch

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:1011:11)
    at Process.ChildProcess._handle.onexit (child_process.js:802:34)

Any idea why? nothing special in package.json

npm-watch does not work from inside Docker

npm-watch runs npm script commands differently compared to running them with only npm run some_script when running from inside a Docker container.

This results in error messages that seems like npm-watch is accessing the host system.
See the following excerp from one of the error messages:
`[dev:scss] npm[dev:scss] [dev:scss] ERR![dev:scss] Darwin 15.3.0

[dev:scss] npm[dev:scss] ERR! argv "/usr/local/Cellar/node/5.5.0/bin/node" "/usr/local/bin/npm" "run" "dev:scss"
[dev:scss] npm ERR![dev:scss] node v5.5.0
[dev:scss] npm [dev:scss] ERR! npm v3.6.0
npm ERR! file[dev:scss] sh
npm ERR! code[dev:scss] ELIFECYCLE
npm ERR![dev:scss] errno ENOENT
[dev:scss] npm ERR! [dev:scss] syscall spawn`

Configure signal

It would be nice to be able to specify the signal argument to nodemon, e.g. to set SIGTERM instead of the default SIGUSR1.

Hide nodemon logs

I wish there is a way to hide all the logs that come with nodemon.

Check this as a reference for nodemon options.

But, you already have an option called --quiet. So do you think there is a way to pass an option that makes nodemon silent (or replace nodemon logs with new ones instead)

I could help if you're planning to implement this.

[Update]: one of the reasons why I'm asking if there's a solution for this is that I'm already using nodemon in my environment and the command line is throwing a lot of unnecessary logs which making the console very complex.

Error when trying to run

I get the following error when I try to run npm run watch

> [email protected] watch /home/ubuntu/bitfinex-api-node
> npm-watch

/home/ubuntu/bitfinex-api-node/node_modules/npm-watch/watch-package.js:96
    stdin.stderr.write(message)
         ^

TypeError: Cannot read property 'stderr' of undefined
    at die (/home/ubuntu/bitfinex-api-node/node_modules/npm-watch/watch-package.js:96:10)
    at watchPackage (/home/ubuntu/bitfinex-api-node/node_modules/npm-watch/watch-package.js:16:5)
    at Object.<anonymous> (/home/ubuntu/bitfinex-api-node/node_modules/npm-watch/cli.js:12:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)

npm ERR! Linux 4.4.0-43-generic
npm ERR! argv "/home/ubuntu/.nvm/versions/node/v6.8.0/bin/node" "/home/ubuntu/.nvm/versions/node/v6.8.0/bin/npm" "run" "watch"
npm ERR! node v6.8.0
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! [email protected] watch: `npm-watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] watch script 'npm-watch'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bitfinex-api-node package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm-watch
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bitfinex-api-node
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bitfinex-api-node
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ubuntu/bitfinex-api-node/npm-debug.log

not sure what happened, but it seems like it is not creating stdin (undefined)

stop callback?

There is a way to execute a task with npm-watch stops?

Warning when missing watch key in package.json

Node v. 7.1

$ npm-watch
/usr/local/lib/node_modules/npm-watch/watch-package.js:96
    stdin.stderr.write(message)
         ^

TypeError: Cannot read property 'stderr' of undefined
    at die (/usr/local/lib/node_modules/npm-watch/watch-package.js:96:10)
    at watchPackage (/usr/local/lib/node_modules/npm-watch/watch-package.js:16:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm-watch/cli.js:12:15)

Should be a message more like Error: Missing watch key in package.json for npm-watch

.vscode dir?

Does this really need to be committed? It's even been gitignored. I consider it junk, especially since I don't use Visual Studio Code.

Run on new file created

[Feature request] It would be nice if the watcher would also trigger when new files are created, that would match a specific pattern.

For example:

package.json

"watch": {
    "copy-assets": "assets/**/*"
},
"scripts": {
   "copy-assets": "cp -R assets/ dist/"
}

That way, if new images are dropped into the assets folder, the would match the pattern and the task would re-run top copy the assets into the dist folder. The current behaviour is, that the newly created file is not picket up by the watcher.

Upgrade nodemon dependency to 1.18.7 to remove event-stream vulnerability

As you're probably aware, event-stream ownership has been unintentionally transferred to a malicious user who injected a vulnerability in it.

npm-watch depends on nodemon ^1.12.1, which depends on event-stream. Few hours ago, nodemon released v.1.18.7 which completely remove the dependency from pstree and subsequently from event-stream.

Is there any chance to upgrade to nodemon 1.18.7, to completely remove event-stream from npm-watch as well? Thanks!

Vulnerability in underlying package

As reported by Snyk (snyk test npm-watch):

✗ Vulnerability found on [email protected]
Info: https://app.snyk.io/vuln/npm:semver:20150403
From: [email protected] > nodemon@~1.0.14 > update-notifier@~0.1.8 > semver@^2.3.0
No direct dependency upgrade can address this issue.
Run `snyk protect -i` to patch this vulnerability
Alternatively, manually upgrade deep dependency semver@^2.3.0 to [email protected]

Upgrading nodemon should probably fix this, as the latest version of nodemon is not vulnerable.

Not working on mac OS

Hello, I'm trying to use it on a mac but the script is not triggering the command when the watched files are modified. (I've tested the same configuration on a Ubuntu OS and is working correctly).

This is my configuration:

  "watch": {
    "compile-less": {
      "patterns": ["src/*"],
      "extensions": "less"
    }
  },
  "scripts": {
    "compile-less:watch": "npm-watch"
  }

Pass arguments to npm script?

"scripts": {
  "build": "node build.js",
  "watch": "npm-watch build"
},
"watch": {
  "build": "*.js"
}
npm run watch -- --param=value

should effectively do:

npm run build --param=value

Unable to get this to run on Windows

Almost certainly related to this: nodejs/node-v0.x-archive#2318

running

C:\Users\Danny\Dev\Portfolio>npm run watch

> DannyFritzPortfolio@0.0.0 watch C:\Users\Danny\Dev\Portfolio
> npm-watch


events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:1001:11)
    at Process.ChildProcess._handle.onexit (child_process.js:792:34)

npm ERR! DannyFritzPortfolio@0.0.0 watch: `npm-watch`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the DannyFritzPortfolio@0.0.0 watch script.
npm ERR! This is most likely a problem with the DannyFritzPortfolio package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm-watch
npm ERR! You can get their info via:
npm ERR!     npm owner ls DannyFritzPortfolio
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
npm ERR! cwd C:\Users\Danny\Dev\Portfolio
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.23
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Danny\Dev\Portfolio\npm-debug.log
npm ERR! not ok code 0

C:\Users\Danny\Dev\Portfolio>

package.json

{
    "name": "DannyFritzPortfolio",
    "version": "0.0.0",
    "description": "Portfolio",
    "main": "",
    "dependencies": {},
    "devDependencies": {
        "browserify": "^5.11.1",
        "eslint": "^0.8.0",
        "mkdirp": "^0.5.0",
        "ncp": "^0.6.0",
        "node-sass": "^0.9.3",
        "npm-watch": "0.0.0"
    },
    "scripts": {
        "test": "npm run test-lint",
        "build": "npm run test && npm run make-folder && npm run build-style && npm run build-scriptt && npm run build-html",
        "watch": "npm-watch",
        "make-folder": "mkdirp dist",
        "test-lint": "eslint scripts",
        "watch-style": "node-sass styles/main.scss dist/main.css --source-comments map --output-style compressed",
        "build-style": "node-sass styles/main.scss dist/main.css --output-style compressed",
        "watch-script": "test-lint && browserify --debug scripts/index.js > dist/app.js",
        "build-script": "browserify scripts/index.js > dist/app.js",
        "watch-html": "ncp html/index.html dist/index.html",
        "build-html": "ncp html/index.html dist/index.html"
    },
    "watch": {
        "watch-style": "styles/*.scss",
        "watch-script": "scripts/*.js",
        "watch-script": "templates/*.hbs",
        "watch-html": "html/*.html"
    },
    "repository": {
        "type": "git",
        "url": "https://github.com/dannyfritz/Portfolio.git"
    },
    "author": "Danny Fritz <[email protected]>",
    "license": "Apache 2.0",
    "readmeFilename": "README.md",
    "gitHead": "32ad43961dd26489a00c0f08be069e539eceab2f"
}

Fails on Node 7

I think problem is same as npm/npm#14438

"Same issue with node 7.0.0, downgrade node to 6.9.0 solved that problem."

"I found that to get around that problem I had to:"

  1. Switch Node from 7.0.0 back to 6.x
  2. Then run npm -g install npm@next (or whatever version you want)
  3. Then switch back to Node 7.0.0
> npm-watch

exception in nodemon killing node
Error: Cannot find module 'internal/fs'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.Module._load (module.js:420:25)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at evalmachine.<anonymous>:17:20
    at Object.<anonymous> (/Users/kristianmandrup/npm/lib/node_modules/nodemon/node_modules/update-notifier/node_modules/configstore/node_modules/graceful-fs/fs.js:11:1)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)

----------------------------------------------------------
If appropriate, please file an error with the output from:
$ /usr/local/bin/node /Users/kristianmandrup/npm/bin/nodemon --ext js,jsx --watch src --watch test --exec npm run test --dump
At http://github.com/remy/nodemon/issues/new
----------------------------------------------------------

Issue when tracking 'Objective-C' files (.m .h) and viewing them in Xcode IDE

Hi,

Love the package but I am having an road block where I get constant watchers triggers in scenario where watching Objective-C files of extension .h and .m . The issue is that if those files are opened in the Xcode IDE and they are being opened (simple navigation between them) their "Last opened" attribute in the file system is changed. This is registered as a change were npm-watch is conceded and a watcher is triggered.

My question is is it possible to tell npm-watch to only watch the content of the files ? This way any "system" changes to that file will not cause a watcher to trigger. In my case what I am trying to achieve is, when a change to one of those (change in its content) files is detected, to trigger a watcher which uses bash to rebuild and iOS framework using xcodebuild. It works but the issue is if I am observing those files via Xcode which is the only iOS IDE when I switch between files in the view the watcher is being triggered multiple times which makes it useless. Any ideas ?

From my research the issue is caused by the "Last opened" attribute of the file in Mac OS. This is changed each time a file is viewed in Xcode and it looks like that is considered a "change" by the npm-watch, which might be true for many cases. Any ideas what can be done so that this can be avoided, I am open to making a contribution to this repo but I have not worked with it so some general guidance can be of great help.

Changed file name as a script variable

When watching over multiple files, it would be helpful if the changed file name would be available as a variable in npm script. For example, convert only changed image instead of them all.

Idea:

{
  "scripts": {
    "convert": "convert ${name}.jpg -resize 50% ${name}.png"
  },
  "watch": {
    "convert": {
      "patterns": [
        "./images"
      ],
      "extensions": "jpg"
    }
  }
}

In this use case, the name should be available without the extension. In other use cases, data like directory, extension and date could be helpful, too.

Line endings break cli.js on Unix Machines

After I upgraded a project to [email protected], it was blowing up on me with the following error:

> npm-watch

/usr/bin/env: ‘node\r’: No such file or directory

npm ERR! Linux 4.4.5-1-ARCH
npm ERR! argv "/home/joe/.nvm/versions/node/v4.4.1/bin/node" "/home/joe/.nvm/versions/node/v4.4.1/bin/npm" "run" "watch"
npm ERR! node v4.4.1
npm ERR! npm  v3.8.3
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] watch: `npm-watch`
npm ERR! spawn ENOENT

So I cloned this repo, did a npm link and it worked fine, giving me the suspicion that this was a line ending issue.

I then installed npm-watch in a local project, it failed with the same issue. After running the following one-liner to clobber the Windows line-endings:

sed 's/\r$//' -i node_modules/npm-watch/cli.js

It worked fine again. This puzzled me because all I saw in the git history was the removal of that console.log().

I did a little research, and this is an open issue with npm and cross-platform compatibility: npm/npm#2097

So if you published from a Windows machine, npm publish sends the \r\n, but then git commit is converting the line endings and commiting \n, so you never see it in the repo.

inherit flag + Jest problem

When I use Jest with npm-watch and use inherit: true, npm-watch doesn't show me the failed tests.

If I don't set inherit it seems to work but I get no coloring.

Is there a solution to make both work?

thanks in advance :)

Change default behavior for output piping

Based on #19, #23,#27 it seems that the textual add-on that npm-watch does has generated a number of issues.
I propose changing the default to simply be passing it along, and if the user explicitly opts-in, the script name could be pre-pended/output would be color stripped.
This allows us to inform the user that the opt-in modes may produce have unpleasant visual effects that are not in our control due to I/O issues.

Tagging @alxndr , @hectormenendez , @domarmstrong, @duivv for feedback as they have been involved in issues/prs related to this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.