create_build_info_js
This script will create a JavaScript file at the given path containing build and source control information.
The given path can either be relative to the base directory (-d
) or an absolute path—intermediate directories will not be created.
The following parameters are optional:
d
-
the base directory (
$PWD
if not given) f
-
overwrite the existing file
The value of
|
The value of The following will give you the timestamp of the HEAD commit:
|
This script will add source control information if the base directory (
The value of |
Usage
$ scripts/web/create_build_info_js.sh build-info.js
$ scripts/web/create_build_info_js.sh -f /tmp/build-info.js
$ scripts/web/create_build_info_js.sh -d ~/git_repo src/build-info.js
$ scripts/web/create_build_info_js.sh src/build-info.js
⇓
/** @type {{build: {id: string, time: string}, git: {commit: {id: string, time: string}, branch: string}}} */
export const buildInfo = {
build: {
id: '1710116787',
time: '2024-03-11T00:26:27Z',
},
git: {
branch: 'main',
commit: {
id: '4768a3cf26cecc00a23be6acdf430809e4bb67a7',
time: '2024-03-11T00:25:48Z',
},
},
};
$ SOURCE_DATE_EPOCH=0 scripts/web/create_build_info_js.sh src/build-info.js
⇓
...
build: {
...
time: '1970-01-01T00:00:00Z',
},
...