forked from nklayman/vue-cli-plugin-electron-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompts.js
57 lines (56 loc) · 1.37 KB
/
prompts.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
const path = require('path')
module.exports = [
{
name: 'electronBuilder.electronVersion',
type: 'list',
message: 'Choose Electron Version',
default: '^4.0.0',
choices: [
{
name: '^2.0.0',
value: '^2.0.0',
short: '^2.0.0'
},
{
name: '^3.0.0',
value: '^3.0.0',
short: '^3.0.0'
},
{
name: '^4.0.0',
value: '^4.0.0',
short: '^4.0.0'
}
],
when: () => {
try {
// Attempt to read package.json
const pkg = require(path.join(process.cwd(), 'package.json'))
// Don't show if electron version is already set
return !pkg.devDependencies.electron
} catch (e) {
console.log('Unable to read package.json')
return true
}
}
},
{
name: 'electronBuilder.addTests',
type: 'confirm',
message: 'Add tests with Spectron to your project?',
when: () => {
try {
// Attempt to read package.json
const pkg = require(path.join(process.cwd(), 'package.json'))
// Don't show if electron version is already set
return (
pkg.devDependencies['@vue/cli-plugin-unit-jest'] ||
pkg.devDependencies['@vue/cli-plugin-unit-mocha']
)
} catch (e) {
console.log('Unable to read package.json')
return false
}
}
}
]