Skip to content

Commit b0ac07d

Browse files
committed
fix: should let the user confirm the detected result
In case the project lies in a monorepo and other packages' dependencies are detected, the user should be able to confirm the detected result.
1 parent 02f16c3 commit b0ac07d

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

bin/create-eslint-config.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,38 @@ let vueVersion
9696
try {
9797
vueVersion = requireInCwd('vue/package.json').version
9898
console.info(dim(`Detected Vue.js version: ${vueVersion}`))
99-
} catch (e) {
100-
// FIXME: warning that this only support Vue 3
99+
} catch {}
100+
101+
if (!vueVersion || !/^3/.test(vueVersion)) {
102+
const { continueAnyway } = await prompt({
103+
type: 'toggle',
104+
disabled: 'No',
105+
enabled: 'Yes',
106+
name: 'continueAnyway',
107+
message: 'Vue 3.x is required but not detected. Continue anyway?',
108+
initial: false
109+
})
110+
if (!continueAnyway) { abort() }
101111
}
102112

103113
// 4. Check TypeScript
104114
// 4.1 Allow JS?
105115
// 4.2 Allow JS in Vue? Allow JSX (TSX, if answered no in 4.1) in Vue?
106-
let hasTypeScript = false
116+
let detectedTypeScript = false
107117
try {
108118
const tsVersion = requireInCwd('typescript/package.json').version
109119
console.info(dim(`Detected TypeScript version: ${tsVersion}`))
110-
hasTypeScript = true
111-
} catch (e) {
112-
const anwsers = await prompt({
113-
type: 'toggle',
114-
disabled: 'No',
115-
enabled: 'Yes',
116-
name: 'hasTypeScript',
117-
message: 'Does your project use TypeScript?',
118-
initial: false
119-
})
120-
hasTypeScript = anwsers.hasTypeScript
121-
}
120+
detectedTypeScript = true
121+
} catch {}
122+
123+
const { hasTypeScript } = await prompt({
124+
type: 'toggle',
125+
disabled: 'No',
126+
enabled: 'Yes',
127+
name: 'hasTypeScript',
128+
message: 'Does your project use TypeScript?',
129+
initial: detectedTypeScript
130+
})
122131

123132
const supportedScriptLangs = {}
124133
// FIXME: Use a multi-select prompt

0 commit comments

Comments
 (0)