Files
react-native-devtools-frontend/scripts/build/generate_html_entrypoint.js
T
Tim van der Lippe 0f7a51b049 Fix duplicate entrypoint naming
In preparation of renaming an entrypoint, I discovered there was
a little bit of duplication in `generate_html_entrypoints`. To ease
renaming and maintenance, let's unify the two.

R=jacktfranklin@chromium.org

Bug: 1228264
Change-Id: I1bc98123ecd2f03e23003611bcd1e571f8c75cfb
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3021230
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-07-12 16:41:25 +00:00

37 lines
1.1 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 {argv} = require('yargs');
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 {entrypoints} = argv;
if (!entrypoints) {
throw new Error('Must specify at least one entrypoint name.');
}
if (!Array.isArray(entrypoints)) {
throw new Error('Must specify multiple entrypoints as array');
}
const templateContent = fs.readFileSync(template, 'utf-8');
for (const entrypoint of entrypoints) {
const rewrittenTemplateContent = templateContent.replace(new RegExp('%ENTRYPOINT_NAME%', 'g'), entrypoint);
fs.writeFileSync(path.join(outDirectory, `${entrypoint}.html`), rewrittenTemplateContent);
}