Giter Site home page Giter Site logo

watch-run's Introduction

watch-run(1)

Note: Check out wait-run or just-wait for better and more recent approaches.

Re-execute a given command everytime something changes in a specific directory. Build upon gaze.

Installation

$ npm install -g watch-run

Usage

Via --help:

Usage: watch-run <cmd>

Options:

  -h, --help               output usage information
  -p, --pattern <pattern>  glob pattern. "," separates multiple patterns.
                           More info: https://github.com/isaacs/minimatch
  -i, --initial            run <cmd> on initial startup
  -d, --delay <n>          delay execution of <cmd> for a number of milliseconds
  -s, --stop-on-error      stop watching and exit when errors occur in <cmd>

Examples:

  # watch dir and execute cmd
  $ watch-run -p 'lib/**' cat package.json

  # watch dir "lib" and "src" and execute cmd
  $ watch-run -p 'lib/**,src/**' cat package.json

Example

$ watch-run -p 'js/modules/**/*.js' browserify main.js -o public/build.js

License

MIT

watch-run's People

Contributors

commenthol avatar duzun avatar minigod avatar queckezz avatar wankdanker avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

watch-run's Issues

Patterns don't work for me!

Hi,

I tried using watch-run (to create css from less) but did not get patterns working.

The following works for me (with npm):

"scripts": { "watch": "watch-run npm run-script less-to-css", "less-to-css": "lessc Content/themes/default/less/styles.less Content/themes/default/css/built/styles.css --source-map=Content/themes/default/css/built/styles.map" }

When running "npm run-script watch" the less file is compiled on any change in the directory.
If I try to restrict the watch-task only on less files it stops working. I tried different patterns:

"scripts": { "watch": "watch-run -p '/Content/**' npm run-script less-to-css", "less-to-css": "lessc Content/themes/default/less/styles.less Content/themes/default/css/built/styles.css --source-map=Content/themes/default/css/built/styles.map" }

"scripts": { "watch": "watch-run -p '*.less' npm run-script less-to-css", "less-to-css": "lessc Content/themes/default/less/styles.less Content/themes/default/css/built/styles.css --source-map=Content/themes/default/css/built/styles.map" }

"scripts": { "watch": "watch-run -p '/Content/themes/default/less/*.less' npm run-script less-to-css", "less-to-css": "lessc Content/themes/default/less/styles.less Content/themes/default/css/built/styles.css --source-map=Content/themes/default/css/built/styles.map" }
None of them worked. Am I doing something wrong or is there a bug?

Error: watch null EPERM

If I use this pattern, create and remove a directory without making any files inside it, then the process hangs and closes.

watch-run -p '*' echo "File Changed"

then, on another terminal

mkdir Test
rmdir Test

back to previous terminal, and


events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: watch null EPERM
    at exports._errnoException (util.js:870:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1217:21)

Multiple patterns to watch

I'd ike to supply multiple patterns to watch. I've tried the following two ways, but neither work.

$ run watch -p 'index.js lib/*.js' -- echo hello
$ run watch -p index.js -p 'lib/*.js' -- echo hello

gaze supports being given an array of patterns, but it looks like commander can't parse multiple -p arguments.

Doesn't work on Windows?

watch-run -p styles/*.less lessc styles/main.less styles/main.css

It hangs, displays no errors, but doesn't make any changes to main.css until I force the process to exit.

Thank you for this!

Thank you for this great work!

It actually inspired two derivative projects:

I am mentioning you as a copyright holder on my fork just-wait.

Just one question:
You are licensing under MIT, @RickWong under BSD-3-clause and myself under Creative Commons.

Is it ok by you if I tell people they can take their pick from these three licenses?

Update dependencies

NPM gives the following annoying warnings when watch-run is installed. I am sorry to say this but this caused me to give npm-watch another shot even though watch-run was more like what I was looking for.

xeli-air:taach xeli$ npm install watch-run -g
npm WARN deprecated [email protected]: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
/usr/local/bin/watch-run -> /usr/local/lib/node_modules/watch-run/bin/watch
/usr/local/lib
└─┬ [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  └─┬ [email protected] 
    └─┬ [email protected] 
      ├─┬ [email protected] 
      │ ├── [email protected] 
      │ └── [email protected] 
      ├── [email protected] 
      └─┬ [email protected] 
        ├── [email protected] 
        └── [email protected] 

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.