mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-02 18:11:04 +08:00
This provides consistency of how imports are order, reducing differences in authored files. Bug: none Change-Id: I45ddd71e3e0004aca32f101cb926101544a34157 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6218490 Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
39 lines
1.1 KiB
JavaScript
39 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 {writeIfChanged} = require('./ninja/write-if-changed.js');
|
|
|
|
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);
|
|
writeIfChanged(path.join(outDirectory, `${entrypoint}.html`), rewrittenTemplateContent);
|
|
}
|