Skip to content

Commit 6c9b5bf

Browse files
author
Paul Korzhyk
committed
Do not abort build if git is not available
1 parent 8f91cd1 commit 6c9b5bf

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

client/config/env.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,20 @@ function getClientEnvironment() {
8080
);
8181

8282
raw.RATEL_BUILT_AT = new Date().toISOString();
83-
raw.RATEL_COMMIT_ID = child_process.execSync('git rev-parse --short HEAD')
84-
.toString()
85-
.trim();
86-
raw.RATEL_COMMIT_INFO = child_process.execSync(`git show --pretty=format:"%h %ad %d" ${JSON.stringify(raw.RATEL_COMMIT_ID)} | head -n1`)
87-
.toString()
88-
.trim();
83+
try {
84+
raw.RATEL_COMMIT_ID = child_process.execSync('git rev-parse --short HEAD')
85+
.toString()
86+
.trim();
87+
} catch(err) {
88+
raw.RATEL_COMMIT_ID = '<not git>'
89+
}
90+
try {
91+
raw.RATEL_COMMIT_INFO = child_process.execSync(`git show --pretty=format:"%h %ad %d" ${JSON.stringify(raw.RATEL_COMMIT_ID)} | head -n1`)
92+
.toString()
93+
.trim();
94+
} catch(err) {
95+
raw.RATEL_COMMIT_INFO = '<UNKNOWN COMMIT>'
96+
}
8997
// Stringify all values so we can feed into Webpack DefinePlugin
9098
const stringified = {
9199
"process.env": Object.keys(raw).reduce((env, key) => {

0 commit comments

Comments
 (0)