-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·48 lines (45 loc) · 1.33 KB
/
index.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
44
45
46
47
48
#!/usr/bin/env node
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const pkg = require('./package.json')
const argv = yargs(hideBin(process.argv))
.version(pkg.version)
.alias('v', 'version')
.command('convert [file] [optionals: --nolint, --clean]', 'Decaffeinate, codemod and lint a file', (yargs) => {
yargs.positional('file', {
describe: 'file to convert',
default: null
}).option('nolint', {
describe: 'Dont lint file post convert'
}).option('clean', {
alias: 'c',
describe: 'Remove .original.coffee files post convert'
})
return yargs
}, (argv) => {
if (!argv.file) {
return console.error('Please provide a file path')
}
const script = require(`./commands/convert.js`);
script(argv)
return argv
})
.command('lint [file]', 'Lint and fix possible issues', (yargs) => {
yargs.positional('file', {
describe: 'file to lint',
default: null
})
return yargs
}, (argv) => {
if (!argv.file) {
return console.error('Please provide a file path')
}
const script = require(`./commands/lint.js`);
script(argv)
return argv
})
.command(require('./commands/update.js'))
.command(require('./commands/reset.js'))
.command(require('./commands/clean.js'))
.help()
.parse()