Files
react-native-devtools-frontend/scripts/build/generate_html_entrypoint.js
T
Tim van der Lippe 96e056291f Generate HTML entrypoints dynamically
This removes the duplication of the multiple HTML entrypoint files
that were defined. It makes sure that all entrypoints honor the
dark mode styling, as well as the proper no-referrer (there were
some files that had these fixes missing).

R=aerotwist@chromium.org

Change-Id: If5022e46c69050d8a7fd3ea695a644d42f4d822c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2410227
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
2020-09-15 11:23:52 +00:00

37 lines
967 B
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 {argv} = require('yargs');
const ENTRYPOINTS = [
'devtools_app',
'inspector',
'js_app',
'ndb_app',
'node_app',
'toolbox',
'worker_app',
];
const {template} = argv;
if (!template) {
throw new Error('Must specify --template location with the location of the HTML entrypoint template.');
}
const {outDirectory} = argv;
if (!outDirectory) {
throw new Error('Must specify --out-directory location where the outputs must live.');
}
const templateContent = fs.readFileSync(template, 'utf-8');
for (const entrypoint of ENTRYPOINTS) {
const rewrittenTemplateContent = templateContent.replace('%ENTRYPOINT_NAME%', entrypoint);
fs.writeFileSync(path.join(outDirectory, `${entrypoint}.html`), rewrittenTemplateContent);
}