Skip to content

Commit 01ecc7c

Browse files
committed
update update_info file
1 parent 4a45607 commit 01ecc7c

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

backend/utils/update_info.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,33 @@ const {
88
namePrefix,
99
} = require(`${basePath}/src/config.js`);
1010

11-
// read json data
12-
let rawdata = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
13-
let data = JSON.parse(rawdata);
11+
(async () => {
12+
// read json data
13+
let rawdata = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
14+
let data = JSON.parse(rawdata);
1415

15-
console.log("Info will be updated using the config.js data.");
16-
const updateName = await yesno(`Update names?`);
17-
const updateDescription = await yesno(`Update descriptions?`);
18-
const updateBaseUri = await yesno(`Update images base URI?`);
16+
console.log("Info will be updated using the config.js data.");
17+
const updateName = await yesno(`Update names?`);
18+
const updateDescription = await yesno(`Update descriptions?`);
19+
const updateBaseUri = await yesno(`Update images base URI?`);
20+
21+
data.forEach((item) => {
22+
if(updateName) item.name = `${namePrefix} #${item.edition}`;
23+
if(updateDescription) item.description = description;
24+
if(updateBaseUri) item.image = `${baseUri}/${item.edition}.png`;
25+
26+
fs.writeFileSync(
27+
`${basePath}/build/json/${item.edition}.json`,
28+
JSON.stringify(item, null, 2)
29+
);
30+
});
1931

20-
data.forEach((item) => {
21-
if(updateName) item.name = `${namePrefix} #${item.edition}`;
22-
if(updateDescription) item.description = description;
23-
if(updateBaseUri) item.image = `${baseUri}/${item.edition}.png`;
24-
2532
fs.writeFileSync(
26-
`${basePath}/build/json/${item.edition}.json`,
27-
JSON.stringify(item, null, 2)
33+
`${basePath}/build/json/_metadata.json`,
34+
JSON.stringify(data, null, 2)
2835
);
29-
});
30-
31-
fs.writeFileSync(
32-
`${basePath}/build/json/_metadata.json`,
33-
JSON.stringify(data, null, 2)
34-
);
3536

36-
if(updateName) console.log(`Updated name prefix for images to ===> ${namePrefix}`);
37-
if(updateBaseUri) console.log(`Updated baseUri for images to ===> ${baseUri}`);
38-
if(updateDescription) console.log(`Updated description for images to ===> ${description}`);
37+
if(updateName) console.log(`Updated name prefix for images to ===> ${namePrefix}`);
38+
if(updateBaseUri) console.log(`Updated baseUri for images to ===> ${baseUri}`);
39+
if(updateDescription) console.log(`Updated description for images to ===> ${description}`);
40+
})()

0 commit comments

Comments
 (0)