Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[test/fixtures/*]
insert_final_newline = false
trim_trailing_whitespace = false
10 changes: 0 additions & 10 deletions .gitattributes

This file was deleted.

51 changes: 0 additions & 51 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,54 +1,3 @@
# Numerous always-ignore extensions
*.DS_Store
*.csv
*.dat
*.diff
*.err
*.gz
*.log
*.orig
*.out
*.pid
*.rej
*.seed
*.swo
*.swp
*.vi
*.yo-rc.json
*.zip
*~
.ruby-version
lib-cov

# OS or Editor folders
*.esproj
*.sublime-project
*.sublime-workspace
._*
.cache
.DS_Store
.idea
.project
.settings
.tmproj
nbproject
Thumbs.db

# Komodo
*.komodoproject
.komodotools

# grunt-html-validation
validation-status.json
validation-report.json

# Vendor packages
node_modules
bower_components
vendor

# General folders and files to ignore
_gh_pages
tmp
temp
TODO.md
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

50 changes: 0 additions & 50 deletions .verb.md

This file was deleted.

21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# watch-cli [![NPM version](https://badge.fury.io/js/watch-cli.svg)](http://badge.fury.io/js/watch-cli)
# watch-cli-only [![NPM version](https://badge.fury.io/js/watch-cli-only.svg)](http://badge.fury.io/js/watch-cli-only)

> Command line wrapper for gaze to use in package.json scripts object.

[chokidar-cli](https://www.npmjs.com/package/chokidar-cli) do the same and is widely used.

### Install globally

**Install globally with [npm](npmjs.org)**

```bash
npm i -g watch-cli
npm i -g watch-cli-only
```

## Usage
Expand Down Expand Up @@ -52,17 +54,22 @@ In Windows:
> watch -p "**/*.js" -c "jshint %FILENAME%"
```

## Author
## Original Author

**Brian Woodward**

+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](http://twitter.com/doowb)

### New Maintainer

From the old `watch-cli` version to the new `watch-cli-only`

**Millicent Billette**

[1forma-tic.fr](https://1forma-tic.fr)


## License
Copyright (c) 2015 Brian Woodward
Released under the MIT license

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 11, 2015._
17 changes: 6 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
const log = require('verbalize');
const gaze = require('gaze');
const path = require('path');
const process = require('process');
const _ = require('lodash');

const exec = require('child_process').exec;
const supportsColor = require('supports-color');
const childEnv = _.assign({
FORCE_COLOR: supportsColor ? 1 : undefined
}, process.env)

var strip = function (str) {
var re = /^=(.*)$/;
Expand All @@ -30,7 +25,7 @@ var watch = function (options) {
};

var runCmd = function(cmd, filepath, event, cb) {
log.write('Running ' + cmd);
console.log('Running ' + cmd);
var env = childEnv;
env.ABSOLUTE_FILENAME = filepath;
env.FILENAME = path.relative(process.cwd(), filepath);
Expand All @@ -48,27 +43,27 @@ var watch = function (options) {
};

gaze(strip(options.pattern), function (err, watcher) {
log.write('Watching started');
console.log('Watching started');

var lastEvent = new Date();
var running = false;
this.on('all', function (event, filepath) {
var now = new Date();
if (!running && (now - lastEvent) > 400) {
running = true;
log.write(filepath + ' ' + event);
console.log(filepath + ' ' + event);

var command = strip(options.command);
if (_.isEmpty(command)) {
log.write('No command found.');
console.log('No command found.');
running = false;
lastEvent = now;
return;
}
runCmd(command, filepath, event, function (err) {
running = false;
log.write('Finished ' + command);
log.write('Watching started');
console.log('Finished ' + command);
console.log('Watching started');
});
lastEvent = now;
}
Expand Down
Loading