UNPKG

@omni-door/utils

Version:

The utils of omni-door's projects

32 lines (31 loc) 913 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tryGitInit = exports.isInGitRepository = void 0; var child_process_1 = require("child_process"); var logger_1 = require("./logger"); function isInGitRepository() { try { child_process_1.execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' }); return true; } catch (e) { return false; } } exports.isInGitRepository = isInGitRepository; function tryGitInit() { try { child_process_1.execSync('git --version', { stdio: 'ignore' }); if (isInGitRepository()) { return false; } child_process_1.execSync('git init', { stdio: 'ignore' }); return true; } catch (e) { logger_1.logWarn(e); logger_1.logWarn('Git repo initialization failed.'); return false; } } exports.tryGitInit = tryGitInit;