mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
chore: Converting a bash script into a javascript file
This commit is contained in:
@@ -17,8 +17,8 @@
|
|||||||
"build:all": "npm run build:deps && npm run build:diagnostic-ui && npm run build:setup-wizard && npm run build:ui",
|
"build:all": "npm run build:deps && npm run build:diagnostic-ui && npm run build:setup-wizard && npm run build:ui",
|
||||||
"start:diagnostic-ui": "npm run copy-git-hash && ionic serve --project diagnostic-ui",
|
"start:diagnostic-ui": "npm run copy-git-hash && ionic serve --project diagnostic-ui",
|
||||||
"start:setup-wizard": "npm run copy-git-hash && ionic serve --project setup-wizard",
|
"start:setup-wizard": "npm run copy-git-hash && ionic serve --project setup-wizard",
|
||||||
"start:ui": "npm run copy-git-hash && ionic serve --project ui",
|
"start:ui": "npm run-script copy-git-hash && ionic serve --project ui",
|
||||||
"copy-git-hash": "./update-git-hash.sh"
|
"copy-git-hash": "node update-git-hash.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^13.2.0",
|
"@angular/animations": "^13.2.0",
|
||||||
|
|||||||
27
frontend/update-git-hash.js
Executable file
27
frontend/update-git-hash.js
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
// @ts-check
|
||||||
|
const fs = require('fs')
|
||||||
|
const childProcess = require('child_process')
|
||||||
|
|
||||||
|
const gitHash = String(childProcess.execSync('git rev-parse HEAD')).trim()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param {() => T} fn
|
||||||
|
* @param {T} defaultValue
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function catchDefault(fn, defaultValue) {
|
||||||
|
try {
|
||||||
|
return fn()
|
||||||
|
} catch {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const origConfig = catchDefault(
|
||||||
|
/** @returns {{gitHash?: string}} */
|
||||||
|
() => JSON.parse(fs.readFileSync('./config.json')),
|
||||||
|
{},
|
||||||
|
)
|
||||||
|
origConfig.gitHash = gitHash
|
||||||
|
fs.writeFileSync('./config.json', JSON.stringify(origConfig, null, 2))
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
TMP_FILE=$(mktemp)
|
|
||||||
|
|
||||||
jq ".gitHash = \"$(git rev-parse HEAD)\"" config.json > $TMP_FILE && mv $TMP_FILE config.json
|
|
||||||
Reference in New Issue
Block a user