forked from ascendancyy/vue-cli-plugin-stylelint
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprompts.js
79 lines (75 loc) · 1.76 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
// these prompts are used if the plugin is late-installed into an existing
// project and invoked by `vue invoke`.
const { chalk, hasGit } = require("@vue/cli-shared-utils");
const { hasStylelintConfig } = require("./utils");
const questions = [
{
name: "config",
type: "list",
message: "Pick a stylelint config:",
default: 0,
when: ({ overwriteConfig }) =>
overwriteConfig ? overwriteConfig !== "abort" : true,
choices: [
{
name: "Recommended",
value: "recommended",
short: "Recommended",
},
{
name: "Prettier",
value: "prettier",
short: "prettier",
},
],
},
{
name: 'scss',
type: 'confirm',
message: 'Include SCSS support',
default: 0,
when: ({ overwriteConfig }) =>
overwriteConfig ? overwriteConfig !== "abort" : true,
},
{
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;