Skip to content

Commit

Permalink
chore: use chokidar for build (#4932)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman authored Jan 7, 2021
1 parent bdf12e3 commit ffa169b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
24 changes: 9 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@types/ws": "7.2.6",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"chokidar": "^3.5.0",
"colors": "^1.4.0",
"commonmark": "^0.29.1",
"cross-env": "^7.0.2",
Expand Down
20 changes: 7 additions & 13 deletions utils/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

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

const steps = [];
const onChanges = [];
Expand All @@ -30,18 +30,12 @@ function filePath(relative) {

function runWatch() {
function runOnChanges(paths, nodeFile) {
for (const p of [...paths, nodeFile]) {
const file = filePath(p);
if (!fs.existsSync(file)) {
console.error('could not find file', file);
process.exit(1);
}
fs.watchFile(file, callback);
}
callback();
nodeFile = filePath(nodeFile);
function callback() {
child_process.spawnSync('node', [filePath(nodeFile)], { stdio: 'inherit' });
child_process.spawnSync('node', [nodeFile], { stdio: 'inherit' });
}
chokidar.watch([...paths, nodeFile].map(filePath)).on('all', callback);
callback();
}

const spawns = [];
Expand Down Expand Up @@ -93,7 +87,7 @@ steps.push({
onChanges.push({
committed: false,
inputs: [
'docs/src/api/*',
'docs/src/api/',
],
script: 'utils/doclint/generateApiJson.js',
});
Expand All @@ -111,7 +105,7 @@ onChanges.push({
onChanges.push({
committed: false,
inputs: [
'docs/src/api/*',
'docs/src/api/',
'utils/generate_types/overrides.d.ts',
'utils/generate_types/exported.json',
'src/server/chromium/protocol.ts',
Expand Down

0 comments on commit ffa169b

Please sign in to comment.