Skip to content

Commit df54a25

Browse files
haoqunjiangAkryum
authored andcommitted
fix: fix compatibility with router/ directories (#146)
The `resolve` method in `GeneratorAPI` only accepts one argument, we need to join the path manually. @vue/cli-plugin-router v4 is directory-based by default so this is a critical compatibility fix. Fixes #32.
1 parent a742953 commit df54a25

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

generator/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs-extra')
2+
const path = require('path')
23
const {
34
hasYarn,
45
} = require('@vue/cli-shared-utils')
@@ -165,9 +166,9 @@ function getFile (api, file) {
165166
if (fs.existsSync(filePath)) return filePath
166167
filePath = api.resolve(file.replace('.js', '.ts'))
167168
if (fs.existsSync(filePath)) return filePath
168-
filePath = api.resolve(file.replace('.js', ''), 'index.js')
169+
filePath = api.resolve(path.join(file.replace('.js', ''), 'index.js'))
169170
if (fs.existsSync(filePath)) return filePath
170-
filePath = api.resolve(file.replace('.js', ''), 'index.ts')
171+
filePath = api.resolve(path.join(file.replace('.js', ''), 'index.ts'))
171172
if (fs.existsSync(filePath)) return filePath
172173

173174
api.exitLog(`File ${file} not found in the project. Automatic generation will be incomplete.`, 'warn')

0 commit comments

Comments
 (0)