Skip to content

Commit

Permalink
chore: add function to update name in manifest.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
mariaozamiz committed May 29, 2024
1 parent 3a2d8f6 commit ac34fc9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function build(args: BuildArgs): void {
run(`react-scripts build && cp -r i18n icon.png build`);
run(`d2-manifest package.json build/manifest.webapp -t ${manifestType} -n '${variant.title}'`);
updateManifestNamespace(`build/manifest.webapp`, variant.file);
updateManifestJsonFile(`build/manifest.json`, variant.title);
run(`rm -f ${fileName}`);
run(`cd build && zip -r ../${fileName} *`);
console.info(`Written: ${fileName}`);
Expand All @@ -153,6 +154,14 @@ function updateManifestNamespace(manifestPath: string, variantFile: string) {
}
}

function updateManifestJsonFile(manifestJsonPath: string, variantTitle: string) {
if (fs.existsSync(manifestJsonPath)) {
const manifestJson = JSON.parse(fs.readFileSync(manifestJsonPath, "utf8"));
Object.assign(manifestJson, { name: variantTitle, short_name: variantTitle });
fs.writeFileSync(manifestJsonPath, JSON.stringify(manifestJson, null, 2));
}
}

/* Start server */

type StartServerArgs = { variant: string; port: number; verbose: boolean };
Expand Down

0 comments on commit ac34fc9

Please sign in to comment.