mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 17:57:36 +08:00
We are building the :front_end target when files change, but this doesn't seem to be broad enough to ensure we build on all changes. This CL updates the target to devtools_frontend_resources, which does seem to be a broader target. This CL also includes a drive-by fix so that the output is sent to stdout. Bug: 1098694 Change-Id: I1d02cc0226767377aa4729af3cf3a734ec774026 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2278471 Auto-Submit: Paul Lewis <aerotwist@chromium.org> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const childProcess = require('child_process');
|
|
const cwd = process.cwd();
|
|
const env = process.env;
|
|
const frontEnd = path.join(cwd, 'front_end');
|
|
|
|
// Extract the target if it's provided.
|
|
let target = 'Default';
|
|
const targetArg = process.argv.find(value => value.startsWith('--target='));
|
|
if (targetArg) {
|
|
target = targetArg.slice('--target='.length);
|
|
}
|
|
|
|
let isBuilding = false;
|
|
let filesChangedDuringBuild = false;
|
|
const onFileChange = () => {
|
|
if (isBuilding) {
|
|
filesChangedDuringBuild = true;
|
|
return;
|
|
}
|
|
|
|
filesChangedDuringBuild = false;
|
|
isBuilding = true;
|
|
|
|
const autoninja = childProcess.spawn(
|
|
'autoninja', ['-C', `out/${target}`, 'devtools_frontend_resources'], {cwd, env, stdio: 'inherit'});
|
|
autoninja.on('close', () => {
|
|
if (filesChangedDuringBuild) {
|
|
console.warn('Warning: files changed during build, you may wish to trigger a fresh rebuild.');
|
|
}
|
|
|
|
isBuilding = false;
|
|
});
|
|
};
|
|
|
|
// Watch the front_end folder and build on any change.
|
|
console.log(`Watching for changes in ${frontEnd}; building to out/${target}`);
|
|
fs.watch(`${frontEnd}`, {recursive: true}, onFileChange);
|