Add warn for git + remove unnecessary import
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}`);
|