chore: use chokidar for build (#4932)

This commit is contained in:
Dmitry Gozman 2021-01-07 13:26:34 -08:00 committed by GitHub
parent bdf12e32e4
commit ffa169ba92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 28 deletions

24
package-lock.json generated
View file

@ -1664,7 +1664,6 @@
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz",
"integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"normalize-path": "^3.0.0", "normalize-path": "^3.0.0",
"picomatch": "^2.0.4" "picomatch": "^2.0.4"
@ -1880,8 +1879,7 @@
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz",
"integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==",
"dev": true, "dev": true
"optional": true
}, },
"bindings": { "bindings": {
"version": "1.5.0", "version": "1.5.0",
@ -2226,15 +2224,14 @@
} }
}, },
"chokidar": { "chokidar": {
"version": "3.4.3", "version": "3.5.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.0.tgz",
"integrity": "sha512-DtM3g7juCXQxFVSNPNByEC2+NImtBuxQQvWlHunpJIS5Ocr0lG306cC7FCi7cEA0fzmybPUIl4txBIobk1gGOQ==", "integrity": "sha512-JgQM9JS92ZbFR4P90EvmzNpSGhpPBGBSj10PILeDyYFwp4h2/D9OM03wsJ4zW1fEp4ka2DGrnUeD7FuvQ2aZ2Q==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"anymatch": "~3.1.1", "anymatch": "~3.1.1",
"braces": "~3.0.2", "braces": "~3.0.2",
"fsevents": "~2.1.2", "fsevents": "~2.3.1",
"glob-parent": "~5.1.0", "glob-parent": "~5.1.0",
"is-binary-path": "~2.1.0", "is-binary-path": "~2.1.0",
"is-glob": "~4.0.1", "is-glob": "~4.0.1",
@ -3683,9 +3680,9 @@
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
}, },
"fsevents": { "fsevents": {
"version": "2.1.3", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.1.tgz",
"integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", "integrity": "sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw==",
"dev": true, "dev": true,
"optional": true "optional": true
}, },
@ -4184,7 +4181,6 @@
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"binary-extensions": "^2.0.0" "binary-extensions": "^2.0.0"
} }
@ -4905,8 +4901,7 @@
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true, "dev": true
"optional": true
}, },
"normalize-url": { "normalize-url": {
"version": "4.5.0", "version": "4.5.0",
@ -5450,7 +5445,6 @@
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz",
"integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"picomatch": "^2.2.1" "picomatch": "^2.2.1"
} }

View file

@ -62,6 +62,7 @@
"@types/ws": "7.2.6", "@types/ws": "7.2.6",
"@typescript-eslint/eslint-plugin": "^3.10.1", "@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1", "@typescript-eslint/parser": "^3.10.1",
"chokidar": "^3.5.0",
"colors": "^1.4.0", "colors": "^1.4.0",
"commonmark": "^0.29.1", "commonmark": "^0.29.1",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",

View file

@ -16,7 +16,7 @@
const child_process = require('child_process'); const child_process = require('child_process');
const path = require('path'); const path = require('path');
const fs = require('fs'); const chokidar = require('chokidar');
const steps = []; const steps = [];
const onChanges = []; const onChanges = [];
@ -30,18 +30,12 @@ function filePath(relative) {
function runWatch() { function runWatch() {
function runOnChanges(paths, nodeFile) { function runOnChanges(paths, nodeFile) {
for (const p of [...paths, nodeFile]) { nodeFile = filePath(nodeFile);
const file = filePath(p);
if (!fs.existsSync(file)) {
console.error('could not find file', file);
process.exit(1);
}
fs.watchFile(file, callback);
}
callback();
function callback() { 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 = []; const spawns = [];
@ -93,7 +87,7 @@ steps.push({
onChanges.push({ onChanges.push({
committed: false, committed: false,
inputs: [ inputs: [
'docs/src/api/*', 'docs/src/api/',
], ],
script: 'utils/doclint/generateApiJson.js', script: 'utils/doclint/generateApiJson.js',
}); });
@ -111,7 +105,7 @@ onChanges.push({
onChanges.push({ onChanges.push({
committed: false, committed: false,
inputs: [ inputs: [
'docs/src/api/*', 'docs/src/api/',
'utils/generate_types/overrides.d.ts', 'utils/generate_types/overrides.d.ts',
'utils/generate_types/exported.json', 'utils/generate_types/exported.json',
'src/server/chromium/protocol.ts', 'src/server/chromium/protocol.ts',