1 | #!/usr/bin/env node
|
2 | import f, { writeFileSync as w } from 'fs'
|
3 | import i from './index.js'
|
4 |
|
5 | let a = process.argv[2]
|
6 |
|
7 | if (a == 'init') {
|
8 | let p = 'package.json'
|
9 | let d = JSON.parse(f.readFileSync(p))
|
10 | ; (d.scripts ||= {}).prepare = 'husky'
|
11 | w('package.json', JSON.stringify(d, null, /\t/.test() ? '\t' : 2) + '\n')
|
12 | process.stdout.write(i())
|
13 | try { f.mkdirSync('.husky') } catch { }
|
14 | w('.husky/pre-commit', process.env.npm_config_user_agent.split('/')[0] + ' test\n')
|
15 | process.exit()
|
16 | }
|
17 |
|
18 | let d = c => console.error(`${c} command is deprecated`)
|
19 | if (['add', 'set', 'uninstall'].includes(a)) { d(a); process.exit(1) }
|
20 | if (a == 'install') d(a)
|
21 |
|
22 | process.stdout.write(i(a == 'install' ? undefined : a)) |
\ | No newline at end of file |