Add commit hash into vite build
This commit is contained in:
parent
eb6d9cdd4b
commit
baad129b49
3 changed files with 21 additions and 2 deletions
18
build/commit_hash.js
Normal file
18
build/commit_hash.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import childProcess from 'child_process'
|
||||
|
||||
export const getCommitHash = (() => {
|
||||
const subst = "$Format:%h$"
|
||||
if(!subst.match(/Format:/)) {
|
||||
return subst
|
||||
} else {
|
||||
try {
|
||||
return childProcess
|
||||
.execSync('git rev-parse --short HEAD')
|
||||
.toString()
|
||||
.trim()
|
||||
} catch (e) {
|
||||
console.error('Failed run git:', e)
|
||||
return 'UNKNOWN'
|
||||
}
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue