diff options
author | uurgothat <cckhmck@gmail.com> | 2021-10-04 22:31:12 +0300 |
---|---|---|
committer | uurgothat <cckhmck@gmail.com> | 2021-10-04 22:31:12 +0300 |
commit | fe5bd56ac8c7c9ce52c29f3bb3384d3bfb8c5441 (patch) | |
tree | 0a00a447a4e8219a576c575a294e9c569e96e029 | |
parent | Rainbow the logs (diff) | |
download | server-fe5bd56ac8c7c9ce52c29f3bb3384d3bfb8c5441.tar.xz |
Add warn for git + remove unnecessary import
-rw-r--r-- | bundle/src/start.ts | 19 | ||||
-rw-r--r-- | bundle/src/stats.ts | 1 |
2 files changed, 14 insertions, 6 deletions
diff --git a/bundle/src/start.ts b/bundle/src/start.ts index cc2053b9..85e15346 100644 --- a/bundle/src/start.ts +++ b/bundle/src/start.ts @@ -3,10 +3,20 @@ import cluster from "cluster"; import os from "os"; import { red, bold, yellow, cyan } from "chalk"; import { initStats } from "./stats"; +import { execSync } from "child_process"; // TODO: add tcp socket event transmission const cores = 1 || Number(process.env.threads) || os.cpus().length; -const commit = require('child_process').execSync('git rev-parse HEAD').toString().trim(); + +export function getCommitOrFail() { + try { + return execSync('git rev-parse HEAD').toString().trim(); + } catch(e) { + return null + } +} +const commit = getCommitOrFail() + console.log(bold(` ███████ ██████ ███████ ███████ ██████ ██████ ██████ ██████ @@ -16,13 +26,12 @@ console.log(bold(` ██ ██████ ███████ ███████ ██████ ██████ ██ ██ ██████ - fosscord-server | ${yellow(`Pre-relase (${commit.slice(0, 7)})`)} + fosscord-server | ${yellow(`Pre-relase (${commit !== null ? commit.slice(0, 7) : "Unknown (Git cannot be found)"})`)} -Current commit: ${cyan(commit)} (${yellow(commit.slice(0, 7))}) +Current commit: ${commit !== null ? `${cyan(commit)} (${yellow(commit.slice(0, 7))})` : "Unknown (Git cannot be found)" } `)) - - +if(commit == null) console.log(yellow(`Warning: Git is not installed or not in PATH.`)) if (cluster.isMaster && !process.env.masterStarted) { process.env.masterStarted = "true"; diff --git a/bundle/src/stats.ts b/bundle/src/stats.ts index 5dc69efe..e6941db2 100644 --- a/bundle/src/stats.ts +++ b/bundle/src/stats.ts @@ -1,6 +1,5 @@ import os from "os"; import osu from "node-os-utils"; -import {} from "chalk"; export function initStats() { console.log(`[Path] running in ${__dirname}`); |