mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: dont throw errors about deviceDescriptors.js on first watch (#9469)
This commit is contained in:
parent
cd99ad0da2
commit
74bb75ce03
@ -46,13 +46,17 @@ function filePath(relative) {
|
|||||||
return path.join(ROOT, ...relative.split('/'));
|
return path.join(ROOT, ...relative.split('/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function runWatch() {
|
async function runWatch() {
|
||||||
function runOnChanges(paths, nodeFile) {
|
function runOnChanges(paths, mustExist = [], nodeFile) {
|
||||||
nodeFile = filePath(nodeFile);
|
nodeFile = filePath(nodeFile);
|
||||||
function callback() {
|
function callback() {
|
||||||
|
for (const fileMustExist of mustExist) {
|
||||||
|
if (!fs.existsSync(filePath(fileMustExist)))
|
||||||
|
return;
|
||||||
|
}
|
||||||
child_process.spawnSync('node', [nodeFile], { stdio: 'inherit' });
|
child_process.spawnSync('node', [nodeFile], { stdio: 'inherit' });
|
||||||
}
|
}
|
||||||
chokidar.watch([...paths, nodeFile].map(filePath)).on('all', callback);
|
chokidar.watch([...paths, ...mustExist, nodeFile].map(filePath)).on('all', callback);
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +76,7 @@ function runWatch() {
|
|||||||
}));
|
}));
|
||||||
process.on('exit', () => spawns.forEach(s => s.kill()));
|
process.on('exit', () => spawns.forEach(s => s.kill()));
|
||||||
for (const onChange of onChanges)
|
for (const onChange of onChanges)
|
||||||
runOnChanges(onChange.inputs, onChange.script);
|
runOnChanges(onChange.inputs, onChange.mustExist, onChange.script);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runBuild() {
|
async function runBuild() {
|
||||||
@ -167,6 +171,10 @@ onChanges.push({
|
|||||||
'utils/generate_types/exported.json',
|
'utils/generate_types/exported.json',
|
||||||
'packages/playwright-core/src/server/chromium/protocol.d.ts',
|
'packages/playwright-core/src/server/chromium/protocol.d.ts',
|
||||||
],
|
],
|
||||||
|
mustExist: [
|
||||||
|
'packages/playwright-core/lib/server/deviceDescriptors.js',
|
||||||
|
'packages/playwright-core/lib/server/deviceDescriptorsSource.json',
|
||||||
|
],
|
||||||
script: 'utils/generate_types/index.js',
|
script: 'utils/generate_types/index.js',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user