Skip to content

Commit 78ab4ef

Browse files
committed
🐞 fix: can't find package.json
1 parent f50470c commit 78ab4ef

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/vue/eslint.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import { compare } from 'compare-versions';
44
// import tsEslintConfig from './tsEslintConfig';
55

66
const isVue3Project = ((packageJsonPath = 'package.json') => {
7-
const json = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
8-
const vueVersion = json.dependencies.vue;
9-
if (!vueVersion) return false;
10-
return compare(vueVersion.replace(/(\~|\^)/gi, ''), '3.0.0', '>=');
7+
try {
8+
const json = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
9+
const vueVersion = json.dependencies.vue;
10+
if (!vueVersion) return false;
11+
return compare(vueVersion.replace(/(\~|\^)/gi, ''), '3.0.0', '>=');
12+
} catch (error) {
13+
return false;
14+
}
1115
})();
1216

1317
const isJsMoreTs = async (path = 'src') => {

0 commit comments

Comments
 (0)