Skip to content

Commit

Permalink
Use chokidar as test watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Apr 12, 2020
1 parent 51b0b2e commit c0c206e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions test/cli/samples/watch/close-stdin/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const stream = require('stream');
const fs = require('fs');
const chokidar = require('chokidar');
const path = require('path');

delete process.stdin;
Expand All @@ -15,12 +16,15 @@ process.stdin = new stream.Readable({
const outputDir = path.resolve(__dirname, '_actual');
fs.mkdirSync(outputDir);
const outputFile = path.resolve(outputDir, 'out.js');
fs.writeFileSync(outputFile, 'NOT WRITTEN');
const INITIAL_OUTPUT = 'NOT WRITTEN';
fs.writeFileSync(outputFile, INITIAL_OUTPUT);

const watcher = fs.watch(outputFile, () => {
watcher.close();
// This closes stdin
process.stdin.push(null);
const watcher = chokidar.watch(outputFile).on('change', () => {
if (fs.readFileSync(outputFile, 'utf8') !== INITIAL_OUTPUT) {
watcher.close();
// This closes stdin
process.stdin.push(null);
}
});

require('../../../../../dist/bin/rollup');
4 changes: 2 additions & 2 deletions test/cli/samples/watch/watch-config-early-update/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
});
`
);
const watcher = fs.watch(messageFile, (event) => {
const watcher = fs.watch(messageFile, event => {
if (event === 'change') {
const content = fs.readFileSync(messageFile, 'utf8');
if (content === 'loading') {
Expand Down Expand Up @@ -69,5 +69,5 @@ module.exports = {
reloadTriggered = true;
return false;
}
},
}
};

0 comments on commit c0c206e

Please sign in to comment.