Created
April 13, 2022 10:57
-
-
Save Mustafa-Omran/bb0810c9e51a1453de8c298b524b217e to your computer and use it in GitHub Desktop.
Angular - Save Build Time At Package.json
This file contains hidden or 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
const { writeFileSync } = require('fs') | |
const { join } = require('path') | |
const BUILD_DATE_TIME_STAMP_PATH = join(__dirname, 'build-date.json'); | |
const createBuildDate = { | |
buildDate: new Date() | |
} | |
writeFileSync(TIME_STAMP_PATH, JSON.stringify(createBuildDate, null, 2)); |
This file contains hidden or 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
"build": "node src/environments/build-date.js && ng build" |
This file contains hidden or 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
"resolveJsonModule": true, |
My implementation for package.json
const { writeFileSync, readFileSync } = require('fs')
const { join } = require('path')
const packageInfo = JSON.parse(readFileSync(join(__dirname, '..', '..', '..', 'package.json')))
const BUILD_DATE_TIME_STAMP_PATH = join(__dirname, '..', '..', '..', 'package.json');
const createBuildDate = {
...packageInfo,
build_version: new Date()
}
writeFileSync(BUILD_DATE_TIME_STAMP_PATH, JSON.stringify(createBuildDate, null, 2));
My implementation for
package.json
const { writeFileSync, readFileSync } = require('fs') const { join } = require('path') const packageInfo = JSON.parse(readFileSync(join(__dirname, '..', '..', '..', 'package.json'))) const BUILD_DATE_TIME_STAMP_PATH = join(__dirname, '..', '..', '..', 'package.json'); const createBuildDate = { ...packageInfo, build_version: new Date() } writeFileSync(BUILD_DATE_TIME_STAMP_PATH, JSON.stringify(createBuildDate, null, 2));
Great @jackz7
thanks @Mustafa-Omran
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can use any file here i used file called build-date.json