UNPKG

1.14 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const lazy_get_decorator_1 = require("lazy-get-decorator");
5const xSpawn_1 = require("../fns/xSpawn");
6class Git {
7 static get originUrl() {
8 const r = xSpawn_1.xSpawnSyncSafe('git', ['config', '--get', 'remote.origin.url']);
9 return (r.ok && r.result.status === 0 && r.result.stdout.trim()) || null;
10 }
11 static add(...files) {
12 if (files.length) {
13 const r = xSpawn_1.xSpawnSyncSafe('git', ['add'].concat(files));
14 return r.ok && r.result.status === 0;
15 }
16 return false;
17 }
18 static cfg(key, val, global = false) {
19 const args = ['config'];
20 if (global) {
21 args.push('--global');
22 }
23 args.push(key, val);
24 const r = xSpawn_1.xSpawnSyncSafe('git', args);
25 return r.ok && r.result.status === 0;
26 }
27}
28tslib_1.__decorate([
29 lazy_get_decorator_1.LazyGetter(),
30 tslib_1.__metadata("design:type", Object),
31 tslib_1.__metadata("design:paramtypes", [])
32], Git, "originUrl", null);
33exports.Git = Git;