Skip to content

Commit

Permalink
Allow --await-write-finish to specify time (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
p-vogt authored and blakeembrey committed Nov 3, 2018
1 parent 402a4c8 commit ba5a1a6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -77,12 +77,12 @@ To set the amount of delay (in ms) between process exits:
onchange -d 1000 '**/*.js' -- npm start
```

### Await Write Finish (`--await-write-finish`)
### Await Write Finish (`--await-write-finish <ms>`)

To hold the events until the size does not change for a configurable amount of time:
To hold the events until the size does not change for a configurable amount of time (in ms, default is [`2000`](https://www.npmjs.com/package/chokidar#performance)):

```sh
onchange --await-write-finish '**/*.js' -- npm test
onchange --await-write-finish 1500 '**/*.js' -- npm test
```

### Poll (`-p <ms>`, `--poll <ms>`)
Expand Down
2 changes: 1 addition & 1 deletion cli.js
Expand Up @@ -6,7 +6,7 @@ var arrify = require('arrify')
// Parse argv with minimist...it's easier this way.
var argv = require('minimist')(process.argv.slice(2), {
'--': true,
boolean: ['v', 'i', 'k', 'await-write-finish'],
boolean: ['v', 'i', 'k'],
string: ['e', 'c', 'killSignal'],
alias: {
jobs: ['j'],
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Expand Up @@ -16,7 +16,7 @@ declare namespace onchange {
stderr?: NodeJS.WritableStream;
outpipe?: string;
filter?: string[];
awaitWriteFinish?: boolean;
awaitWriteFinish?: boolean | number;
}
}

Expand Down
4 changes: 3 additions & 1 deletion index.js
Expand Up @@ -90,7 +90,9 @@ function onchange (match, command, rawargs, opts = {}) {
const args = rawargs ? rawargs.map(tmpl) : []
const outpipe = typeof opts.outpipe === 'string' ? outpipetmpl(opts.outpipe) : undefined
const filter = opts.filter || []
const awaitWriteFinish = !!opts.awaitWriteFinish
const awaitWriteFinish = typeof opts.awaitWriteFinish === 'number'
? { stabilityThreshold: opts.awaitWriteFinish }
: !!opts.awaitWriteFinish
const running = new Set()
const queue = new Deque()

Expand Down

0 comments on commit ba5a1a6

Please sign in to comment.