Add warn for git + remove unnecessary import

This commit is contained in:
uurgothat 2021-10-04 22:31:12 +03:00
parent d4ddf3acf0
commit 4ea441ca1d
2 changed files with 14 additions and 6 deletions

View File

@ -3,10 +3,20 @@ import cluster from "cluster";
import os from "os"; import os from "os";
import { red, bold, yellow, cyan } from "chalk"; import { red, bold, yellow, cyan } from "chalk";
import { initStats } from "./stats"; import { initStats } from "./stats";
import { execSync } from "child_process";
// TODO: add tcp socket event transmission // TODO: add tcp socket event transmission
const cores = 1 || Number(process.env.threads) || os.cpus().length; 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(` 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) { if (cluster.isMaster && !process.env.masterStarted) {
process.env.masterStarted = "true"; process.env.masterStarted = "true";

View File

@ -1,6 +1,5 @@
import os from "os"; import os from "os";
import osu from "node-os-utils"; import osu from "node-os-utils";
import {} from "chalk";
export function initStats() { export function initStats() {
console.log(`[Path] running in ${__dirname}`); console.log(`[Path] running in ${__dirname}`);