-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathprompts.js
84 lines (79 loc) · 1.94 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// these prompts are used if the plugin is late-installed into an existing
// project and invoked by `vue invoke`.
const inquirer = require('inquirer');
const chalk = require('chalk');
const { execSync } = require('child_process');
const { hasStylelintConfig } = require('./utils');
let git;
function hasGit() {
if (git != null) {
return git;
}
try {
execSync('git --version', { stdio: 'ignore' });
git = true;
} catch (e) {
git = false;
}
return git;
}
const questions = [
{
name: 'config',
type: 'list',
message: 'Pick a stylelint config:',
default: 0,
when: ({ overwriteConfig }) => (overwriteConfig ? overwriteConfig !== 'abort' : true),
choices: [
{
name: 'Standard',
value: 'stylelint-config-standard',
short: 'Standard',
}, {
name: 'Primer',
value: 'stylelint-config-primer',
short: 'Primer',
},
new inquirer.Separator(),
{
name: 'Kanbaru',
value: '@ascendancyy/stylelint-config-kanbaru',
short: 'Kanbaru',
},
],
}, {
name: 'lintStyleOn',
type: 'checkbox',
message: 'Pick additional stylelint features:',
when: ({ overwriteConfig }) => (overwriteConfig ? overwriteConfig !== 'abort' : true),
choices: [
{
name: 'Lint on build',
value: 'build',
}, {
name: `Lint and fix on commit ${hasGit() ? '' : chalk`{red (requires Git)}`}`,
value: 'commit',
},
],
},
];
const cwd = process.cwd();
if (hasStylelintConfig(cwd)) {
questions.unshift({
name: 'overwriteConfig',
type: 'expand',
message: 'Existing stylelint config found:',
choices: [
{
key: 'y',
name: 'Overwrite',
value: 'overwrite',
}, {
key: 'x',
name: 'Cancel setup (Plugin generator will be invoked, but will not make changes)',
value: 'abort',
},
],
});
}
module.exports = questions;