-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·47 lines (43 loc) · 1.16 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
#!/usr/bin/env node
const program = require('commander')
const chalk = require('chalk')
const transform = require('./lib/index')
program
.option('-s, --src <path>', 'source file path, which can be a directory or a file path(default:PWD)')
.option('-o, --out <path>', 'output file directory(default: temp_out)')
.option('-e, --empty', 'empty the target directory(default: false)')
.option(
'-q, --quiet',
'disabled transform success log(default: false)'
)
.option(
'-i, --ignore <ignoredir>',
'ignore list of folders(default: "")',
(value) => {
return value.split(/\s+/)
}
)
.option(
'-f, --format',
"format the file content(default: false)"
)
.action((options) => {
transform(options)
.then(() => {
console.log()
process.exit(1)
})
.catch((err) => {
console.log(chalk.red(err))
process.exit(1)
})
})
program
.version(require('./package').version)
.description(chalk.green('transform style of vue2 from scoped to css module'))
program.exitOverride();
try {
program.parse(process.argv);
} catch (err) {
err.code === 'commander.unknownOption' && console.log(chalk.yellow('(add --help for additional information)'))
}