-
Notifications
You must be signed in to change notification settings - Fork 0
/
pleasure-create.config.js
64 lines (62 loc) · 1.28 KB
/
pleasure-create.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const path = require('path')
const empty = v => {
return /^[\s]*$/.test(v)
}
module.exports = {
// see `inquirer.prompt` in https://github.com/SBoudrias/Inquirer.js/
savePreset: ['author'],
prompts (dest) {
return [
{
name: 'author',
message: 'Author name'
},
{
name: 'projectName',
message: 'Project name',
default: path.basename(dest),
validate (n) {
return empty(n) ? 'Enter a valid project name' : true
}
},
{
type: 'checkbox',
name: 'config',
message: 'Distribute for',
choices: [
{
name: 'cjs',
value: 'cjs',
checked: true
},
{
name: 'esm',
value: 'esm',
checked: true
},
{
name: 'iife',
value: 'iife',
checked: false
}
]
},
{
name: 'iifeName',
message: 'iife module name',
when (a) {
return a.config.indexOf('iife') >= 0
}
}
]
},
transform (data) {
const config = {}
data.config.forEach(v => {
config[v] = true
})
data.year = new Date().getFullYear()
data.config = config
return data
}
}