Skip to content

Commit 9079d3e

Browse files
author
Guillaume Chau
committed
fix(deps): more robust isInstalled
1 parent 316d476 commit 9079d3e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/@vue/cli-ui/apollo-server/connectors/dependencies.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function findDependencies (deps, type, file, context) {
6060
id => ({
6161
id,
6262
versionRange: deps[id],
63-
installed: fs.existsSync(getPath({ id, file })),
63+
installed: isInstalled({ id, file }),
6464
website: getLink({ id, file }, context),
6565
type,
6666
baseFir: file
@@ -70,9 +70,15 @@ function findDependencies (deps, type, file, context) {
7070

7171
function getPath ({ id, file = cwd.get() }) {
7272
const filePath = resolveModule(path.join(id, 'package.json'), file)
73+
if (!filePath) return
7374
return resolveModuleRoot(filePath, id)
7475
}
7576

77+
function isInstalled ({ id, file = cwd.get() }) {
78+
const resolvedPath = getPath({ id, file })
79+
return resolvedPath && fs.existsSync(resolvedPath)
80+
}
81+
7682
function readPackage ({ id, file }, context) {
7783
try {
7884
return folders.readPackage(getPath({ id, file }), context)

0 commit comments

Comments
 (0)