Skip to content

Commit

Permalink
update update_info file
Browse files Browse the repository at this point in the history
  • Loading branch information
codeSTACKr committed Mar 24, 2022
1 parent 4a45607 commit 01ecc7c
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions backend/utils/update_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,33 @@ const {
namePrefix,
} = require(`${basePath}/src/config.js`);

// read json data
let rawdata = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
let data = JSON.parse(rawdata);
(async () => {
// read json data
let rawdata = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
let data = JSON.parse(rawdata);

console.log("Info will be updated using the config.js data.");
const updateName = await yesno(`Update names?`);
const updateDescription = await yesno(`Update descriptions?`);
const updateBaseUri = await yesno(`Update images base URI?`);
console.log("Info will be updated using the config.js data.");
const updateName = await yesno(`Update names?`);
const updateDescription = await yesno(`Update descriptions?`);
const updateBaseUri = await yesno(`Update images base URI?`);

data.forEach((item) => {
if(updateName) item.name = `${namePrefix} #${item.edition}`;
if(updateDescription) item.description = description;
if(updateBaseUri) item.image = `${baseUri}/${item.edition}.png`;

fs.writeFileSync(
`${basePath}/build/json/${item.edition}.json`,
JSON.stringify(item, null, 2)
);
});

data.forEach((item) => {
if(updateName) item.name = `${namePrefix} #${item.edition}`;
if(updateDescription) item.description = description;
if(updateBaseUri) item.image = `${baseUri}/${item.edition}.png`;

fs.writeFileSync(
`${basePath}/build/json/${item.edition}.json`,
JSON.stringify(item, null, 2)
`${basePath}/build/json/_metadata.json`,
JSON.stringify(data, null, 2)
);
});

fs.writeFileSync(
`${basePath}/build/json/_metadata.json`,
JSON.stringify(data, null, 2)
);

if(updateName) console.log(`Updated name prefix for images to ===> ${namePrefix}`);
if(updateBaseUri) console.log(`Updated baseUri for images to ===> ${baseUri}`);
if(updateDescription) console.log(`Updated description for images to ===> ${description}`);
if(updateName) console.log(`Updated name prefix for images to ===> ${namePrefix}`);
if(updateBaseUri) console.log(`Updated baseUri for images to ===> ${baseUri}`);
if(updateDescription) console.log(`Updated description for images to ===> ${description}`);
})()

0 comments on commit 01ecc7c

Please sign in to comment.