UNPKG

youzanyun-devtool-worker

Version:

- web - ws - proxy

52 lines (51 loc) 1.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const spring4js_nodejs_1 = require("spring4js-nodejs"); let GitService = class GitService { constructor() { } async start() { } async getGitInfo(gitRepoDir) { const gitInfo = {}; try { const remoteInfo = await this.executeService.promiseExec('git remote -v', { cwd: gitRepoDir, }); const appNameArr = remoteInfo.split('/').pop().split('.'); gitInfo.appName = appNameArr.slice(0, appNameArr.length - 1).join('/'); const username = await this.executeService.promiseExec('git config user.name', { cwd: gitRepoDir, }); gitInfo.username = username || 'unknown'; const commitId = await this.executeService.promiseExec('git rev-parse HEAD', { cwd: gitRepoDir, }); gitInfo.commitId = commitId; return gitInfo; } catch (error) { console.log(error); return gitInfo; } } async checkGitRepoClean(gitRepoDir) { try { const statusInfo = await this.executeService.promiseExec('git status -s', { cwd: gitRepoDir }); return !statusInfo; } catch (error) { return false; } } }; tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], GitService.prototype, "executeService", void 0); GitService = tslib_1.__decorate([ spring4js_nodejs_1.Service() ], GitService); exports.default = GitService;