From ffa169ba92e4c8444b4acb3bacc7646ba95758c2 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 7 Jan 2021 13:26:34 -0800 Subject: [PATCH] chore: use chokidar for build (#4932) --- package-lock.json | 24 +++++++++--------------- package.json | 1 + utils/build/build.js | 20 +++++++------------- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index d733fb470e..b8ca89c893 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1664,7 +1664,6 @@ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", "dev": true, - "optional": true, "requires": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -1880,8 +1879,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz", "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", - "dev": true, - "optional": true + "dev": true }, "bindings": { "version": "1.5.0", @@ -2226,15 +2224,14 @@ } }, "chokidar": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz", - "integrity": "sha512-DtM3g7juCXQxFVSNPNByEC2+NImtBuxQQvWlHunpJIS5Ocr0lG306cC7FCi7cEA0fzmybPUIl4txBIobk1gGOQ==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.0.tgz", + "integrity": "sha512-JgQM9JS92ZbFR4P90EvmzNpSGhpPBGBSj10PILeDyYFwp4h2/D9OM03wsJ4zW1fEp4ka2DGrnUeD7FuvQ2aZ2Q==", "dev": true, - "optional": true, "requires": { "anymatch": "~3.1.1", "braces": "~3.0.2", - "fsevents": "~2.1.2", + "fsevents": "~2.3.1", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -3683,9 +3680,9 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", - "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.1.tgz", + "integrity": "sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw==", "dev": true, "optional": true }, @@ -4184,7 +4181,6 @@ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "dev": true, - "optional": true, "requires": { "binary-extensions": "^2.0.0" } @@ -4905,8 +4901,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "optional": true + "dev": true }, "normalize-url": { "version": "4.5.0", @@ -5450,7 +5445,6 @@ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", "dev": true, - "optional": true, "requires": { "picomatch": "^2.2.1" } diff --git a/package.json b/package.json index 556f152849..af55cc53e0 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/utils/build/build.js b/utils/build/build.js index 0556245600..a4b001af78 100644 --- a/utils/build/build.js +++ b/utils/build/build.js @@ -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 = []; @@ -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 = []; @@ -93,7 +87,7 @@ steps.push({ onChanges.push({ committed: false, inputs: [ - 'docs/src/api/*', + 'docs/src/api/', ], script: 'utils/doclint/generateApiJson.js', }); @@ -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',