forked from abranhe/openup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
39 lines (33 loc) · 746 Bytes
/
cli.js
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
#!/usr/bin/env node
'use strict';
const exec = require('child_process');
const isGit = require('is-git-repository');
const meow = require('meow');
const cli = meow(`
Usage:
$ openup
Flags:
-h, --help Show help message and close
-v, --version View package version
`, {
flags: {
help: {
type: 'boolean',
alias: 'h'
},
version: {
type: 'boolean',
alias: 'v'
}
}
});
const open = () => {
exec.exec(`git remote -v | awk '/origin.*push/ {print $2}' | xargs open`, (error, stdout, stderr) => {
console.log(`${stdout}`);
console.log(`${stderr}`);
if (error !== null) {
console.log(`exec error: ${error}`);
}
})
};
isGit() ? open() : console.log('The directory isn\'t a git repository :(');