UNPKG

@omni-door/utils

Version:

The utils of omni-door's projects

33 lines (32 loc) 956 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 init failed'); logger_1.logWarn('Git仓库初始化失败'); return false; } } exports.tryGitInit = tryGitInit;