2020-08-20 19:27:04 +03:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const child_process = require('child_process');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const spawns = [
|
|
|
|
child_process.spawn('node', [path.join(__dirname, 'runWebpack.js'), '--mode="development"', '--watch', '--silent'], { stdio: 'inherit', shell: true }),
|
2020-09-26 01:25:54 +03:00
|
|
|
child_process.spawn('npx', ['tsc', '-w', '--preserveWatchOutput', '-p', path.join(__dirname, '..')], { stdio: 'inherit', shell: true }),
|
2020-08-20 19:27:04 +03:00
|
|
|
];
|
|
|
|
process.on('exit', () => spawns.forEach(s => s.kill()));
|
|
|
|
|
2020-08-22 04:46:11 +03:00
|
|
|
runOnChanges(['src/protocol/protocol.yml'], 'utils/generate_channels.js');
|
2020-12-27 00:52:05 +03:00
|
|
|
runOnChanges([
|
2020-12-28 21:54:47 +03:00
|
|
|
'docs-src/api-body.md',
|
|
|
|
'docs-src/api-params.md',
|
2020-12-27 00:52:05 +03:00
|
|
|
'utils/generate_types/overrides.d.ts',
|
|
|
|
'utils/generate_types/exported.json',
|
|
|
|
'src/server/chromium/protocol.ts',
|
|
|
|
'src/trace/traceTypes.ts',
|
|
|
|
], 'utils/generate_types/index.js');
|
2020-08-20 19:27:04 +03:00
|
|
|
|
|
|
|
/**
|
2020-08-22 04:46:11 +03:00
|
|
|
* @param {string[][]} paths
|
2020-08-20 19:27:04 +03:00
|
|
|
* @param {string} nodeFile
|
|
|
|
*/
|
|
|
|
function runOnChanges(paths, nodeFile) {
|
|
|
|
for (const p of [...paths, nodeFile]) {
|
|
|
|
const filePath = path.join(__dirname, '..', ...p.split('/'));
|
|
|
|
if (!fs.existsSync(filePath)) {
|
|
|
|
console.error('could not find file', filePath);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
fs.watchFile(filePath, callback);
|
|
|
|
}
|
2020-08-22 04:46:11 +03:00
|
|
|
|
2020-08-20 19:27:04 +03:00
|
|
|
callback();
|
2020-08-22 04:46:11 +03:00
|
|
|
|
2020-08-20 19:27:04 +03:00
|
|
|
function callback() {
|
|
|
|
child_process.spawnSync('node', [path.join(__dirname, '..', ...nodeFile.split('/'))]);
|
|
|
|
}
|
|
|
|
}
|