-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (26 loc) · 732 Bytes
/
index.js
File metadata and controls
33 lines (26 loc) · 732 Bytes
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
import execa from 'execa';
import { platform } from 'os';
import path from 'path';
import isGit from 'is-git-repository';
import pathIsAbsolute from 'path-is-absolute';
const cwd = process.cwd();
const getRemotes = (altPath = cwd) => {
let remotes;
const thisPath = pathIsAbsolute(altPath) ? altPath : path.join(cwd, altPath);
if (!isGit(thisPath)) {
return '';
}
try {
let checkRemoteExec;
if (platform() === 'win32') {
checkRemoteExec = `pushd ${thisPath} & git remote -v`;
} else {
checkRemoteExec = `(cd ${thisPath} ; git remote -v)`;
}
remotes = execa.shellSync(checkRemoteExec).stdout;
return remotes;
} catch (err) {
return '';
}
};
export default getRemotes;