forked from rthor/cra-generate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·27 lines (23 loc) · 823 Bytes
/
index.js
File metadata and controls
executable file
·27 lines (23 loc) · 823 Bytes
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
#!/usr/bin/env node
'use strict'
const commander = require('commander')
const chalk = require('chalk')
const getConfig = require('./config')
const generate = require('./generate')
const { version } = require('./package.json')
let component = null
const program = commander
.version(version)
.option('-f, --functional', 'create a functional component')
.option('-t, --type-check [system]', 'add @flow comment to script files')
.option('-d, --directory [dir]', 'specify a directory for the component')
.arguments('<component>')
.action((c) => component = c)
.parse(process.argv)
if (component == null) {
console.error('A component’s name is required.')
console.log(` ${chalk.cyan(program.name())} ${chalk.green('<component>')}`)
process.exit(1)
} else {
generate(component, getConfig(program))
}