mirror of
https://github.com/thelounge/thelounge
synced 2024-11-10 06:34:21 +00:00
Fix git commit not being available in dist build
This commit is contained in:
parent
c816e4053e
commit
2f04150461
2 changed files with 7 additions and 8 deletions
|
@ -44,23 +44,23 @@ function getVersionNumber() {
|
|||
return pkg.version;
|
||||
}
|
||||
|
||||
let _fetchedGitCommit = false;
|
||||
let _gitCommit: string | null = null;
|
||||
|
||||
function getGitCommit() {
|
||||
if (_gitCommit) {
|
||||
if (_fetchedGitCommit) {
|
||||
return _gitCommit;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(path.resolve(__dirname, "..", ".git"))) {
|
||||
_gitCommit = null;
|
||||
return null;
|
||||
}
|
||||
_fetchedGitCommit = true;
|
||||
|
||||
// --git-dir ".git" makes git only check current directory for `.git`, and not travel upwards
|
||||
// We set cwd to the location of `index.js` as soon as the process is started
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
_gitCommit = require("child_process")
|
||||
.execSync(
|
||||
"git rev-parse --short HEAD", // Returns hash of current commit
|
||||
'git --git-dir ".git" rev-parse --short HEAD', // Returns hash of current commit
|
||||
{stdio: ["ignore", "pipe", "ignore"]}
|
||||
)
|
||||
.toString()
|
||||
|
|
|
@ -9,7 +9,6 @@ import colors from "chalk";
|
|||
import net from "net";
|
||||
|
||||
import log from "./log";
|
||||
import pkg from "../package.json";
|
||||
import Client from "./client";
|
||||
import ClientManager from "./clientManager";
|
||||
import Uploader from "./plugins/uploader";
|
||||
|
@ -885,7 +884,7 @@ function getClientConfiguration(): ClientConfiguration {
|
|||
|
||||
config.isUpdateAvailable = changelog.isUpdateAvailable;
|
||||
config.applicationServerKey = manager!.webPush.vapidKeys!.publicKey;
|
||||
config.version = pkg.version;
|
||||
config.version = Helper.getVersionNumber();
|
||||
config.gitCommit = Helper.getGitCommit();
|
||||
config.themes = themes.getAll();
|
||||
config.defaultTheme = Config.values.theme;
|
||||
|
|
Loading…
Reference in a new issue