-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfgh.ts
More file actions
48 lines (39 loc) · 1.01 KB
/
fgh.ts
File metadata and controls
48 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { exec } from "child_process";
export function getProjectPath(name: string): Promise<string> {
return new Promise((resolve, reject) => {
exec(`fgh ls "${name}"`, (err, stdout) => {
if (err) {
reject(err);
return;
}
resolve(stdout.trim());
});
});
}
export function getProjectList(): Promise<{ [key: string]: string }> {
return new Promise((resolve, reject) => {
exec("fgh visualize --ownerName", (err, stdout) => {
if (err) {
reject(err);
return;
}
const lines = stdout.trim().split("\n");
const projects: { [key: string]: string } = {};
for (let i = 0; i < lines.length / 2; i++) {
projects[lines[i * 2]] = lines[i * 2 + 1];
}
resolve(projects);
});
});
}
export function cloneRepo(name: string): Promise<void> {
return new Promise((resolve, reject) => {
exec(`fgh clone "${name}"`, (err) => {
if (err) {
reject(err);
return;
}
resolve();
});
});
}