-
Notifications
You must be signed in to change notification settings - Fork 25
/
cli.js
32 lines (26 loc) · 777 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
#!/usr/bin/env node
const fn = require('./')
const { execSync } = require('child_process')
function printHelp () {
console.log('Usage: node ' + process.argv[1] + ' <[email protected]> [destination]')
console.log('Or: covgen <[email protected]> [destination] (if installed globally)')
}
if (!process.argv.every(val => val.match(/(--help|-h)/) === null)) {
printHelp()
process.exit(0)
}
if (process.argv[0] !== 'covgen') {
process.argv.shift()
}
let email = process.argv[1]
const dest = process.argv[2]
if (email === undefined) {
try {
email = execSync('git config --get user.email').toString().trim()
console.log('No email provided, using the email in your .gitconfig...')
} catch {
printHelp()
process.exit(1)
}
}
fn(email, dest)