Created
February 26, 2020 09:54
-
-
Save michchan/037b0712c5ae44017fc267663a2806a3 to your computer and use it in GitHub Desktop.
Script to generate a build ID and write to "src/buildMetadata.json"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Execute script: node scripts/generateBuildId.js | |
*/ | |
// Ref: https://github.com/facebook/create-react-app/issues/1917 | |
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | |
// @ts-ignore: ts(1208) | |
const fs = require('fs'); | |
console.log("Incrementing build number..."); | |
fs.readFile('src/buildMetadata.json',function(err,content){ | |
if(err) throw err; | |
const buildMetadata = JSON.parse(content); | |
buildMetadata.build += 1; | |
fs.writeFile('src/buildMetadata.json',JSON.stringify(buildMetadata),function(err){ | |
if(err) throw err; | |
console.log("Next build number: " + buildMetadata.build); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment