forked from rthor/cra-generate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
45 lines (34 loc) · 950 Bytes
/
config.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
'use strict'
const fs = require('fs')
const path = require('path')
let pkg = {}
try {
pkg = require(path.resolve(process.cwd(), 'package.json'))
} catch (err) {}
const defaultOptions = {
directory: 'components',
typeCheck: fs.existsSync(path.join(process.cwd(), '.flowconfig')) && 'flow',
cssExtension: 'css',
semi: true,
fileFormat: 'pascalCase',
componentFormat: 'pascalCase',
test: 'jest',
}
module.exports = function (program) {
const config = Object.assign({}, defaultOptions, pkg.craGenerate || {})
config.isFunctional = Boolean(program.functional)
config.semi = program.semi
if (program.test) {
config.test = program.test === 'none' ? false : program.test
}
if (program.cssExtension) {
config.cssExtension = program.cssExtension
}
if (program.typeCheck) {
config.typeCheck = program.typeCheck
}
if (program.directory) {
config.directory = program.directory
}
return config
}