-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
bin.js
43 lines (34 loc) · 915 Bytes
/
bin.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
40
41
42
43
#!/usr/bin/env node
const pkg = require('./package.json')
const { enableAndSave, disableAndSave } = require('./index')
const usage = `Usage
$ pinst
Options
--enable, -e Enable postinstall hook
--disable, -d Disable postinstall hook
--silent, -s
Examples
$ pinst --enable`
function run(args) {
// Silent
const silent = args.includes('--silent') || args.includes('-s')
// Enable
if (args.includes('--enable') || args.includes('-e')) {
if (!silent) console.log('pinst enable')
return enableAndSave()
}
// Disable
if (args.includes('--disable') || args.includes('-d')) {
if (!silent) console.log('pinst disable')
return disableAndSave()
}
// Version
if (args.includes('--version') || args.includes('-v')) {
return console.log(pkg.version)
}
// No known flag provided
console.log(usage)
process.exit(1)
}
const [, , ...args] = process.argv
run(args)