1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const utils_fs_1 = require("@ionic/utils-fs");
|
4 | const path = require("path");
|
5 | async function isGitInstalled({ shell }) {
|
6 | return Boolean(await shell.cmdinfo('git', ['--version']));
|
7 | }
|
8 | exports.isGitInstalled = isGitInstalled;
|
9 | async function getTopLevel({ shell }) {
|
10 | return shell.cmdinfo('git', ['rev-parse', '--show-toplevel']);
|
11 | }
|
12 | exports.getTopLevel = getTopLevel;
|
13 | async function isRepoInitialized(dir) {
|
14 | return utils_fs_1.pathExists(path.join(dir, '.git'));
|
15 | }
|
16 | exports.isRepoInitialized = isRepoInitialized;
|
17 | async function initializeRepo({ shell }, dir) {
|
18 | await shell.run('git', ['init'], { cwd: dir });
|
19 | }
|
20 | exports.initializeRepo = initializeRepo;
|
21 | async function getIonicRemote({ shell }, dir) {
|
22 | const regex = /ionic\t(.+) \(\w+\)/;
|
23 |
|
24 | const remotes = await shell.output('git', ['remote', '-v'], { cwd: dir });
|
25 | for (const line of remotes.split('\n')) {
|
26 | const match = regex.exec(line.trim());
|
27 | if (match) {
|
28 | return match[1];
|
29 | }
|
30 | }
|
31 | }
|
32 | exports.getIonicRemote = getIonicRemote;
|
33 | async function addIonicRemote({ shell }, dir, url) {
|
34 | await shell.run('git', ['remote', 'add', 'ionic', url], { cwd: dir });
|
35 | }
|
36 | exports.addIonicRemote = addIonicRemote;
|
37 | async function setIonicRemote({ shell }, dir, url) {
|
38 | await shell.run('git', ['remote', 'set-url', 'ionic', url], { cwd: dir });
|
39 | }
|
40 | exports.setIonicRemote = setIonicRemote;
|