Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
fix: await flush files when using --watch mode on Windows (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 authored and teppeis committed Apr 20, 2018
1 parent 6ba5452 commit 74bf99a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
8 changes: 4 additions & 4 deletions docs/dist/bundle.js

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const path = require('path');
const fs = require('fs');
const os = require('os');
const chokidar = require('chokidar');
const denodeify = require('denodeify');

Expand Down Expand Up @@ -71,7 +72,19 @@ function cli(pluginDir, options) {
}

if (options.watch) {
const watcher = chokidar.watch(pluginDir);
// change events are fired before chagned files are flushed on Windows,
// which generate an invalid plugin zip.
// in order to fix this, we use awaitWriteFinish option only on Windows.
const watchOptions =
os.platform() === 'win32'
? {
awaitWriteFinish: {
stabilityThreshold: 1000,
pollInterval: 250,
},
}
: {};
const watcher = chokidar.watch(pluginDir, watchOptions);
watcher.on('change', () => {
cli(pluginDir, Object.assign({}, options, {watch: false}));
});
Expand Down

0 comments on commit 74bf99a

Please sign in to comment.