fix(nitro): read firebase package.json (#1108)

This commit is contained in:
retsuki 2021-10-18 16:53:50 +09:00 committed by GitHub
parent de4a3a2ce6
commit b3ff8eeaed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,8 +134,16 @@ export function readPackageJson (
return _require(`${packageName}/package.json`)
} catch (error) {
if (error.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
const [pkgModulePath] = /^(.*\/node_modules\/).*$/.exec(_require.resolve(packageName))
return fse.readJSONSync(resolve(pkgModulePath, packageName, 'package.json'))
const pkgModulePaths = /^(.*\/node_modules\/).*$/.exec(_require.resolve(packageName))
for (const pkgModulePath of pkgModulePaths) {
const path = resolve(pkgModulePath, packageName, 'package.json')
if (fse.existsSync(path)) {
return fse.readJSONSync(path)
}
continue
}
throw error
}
throw error
}