Skip to content

Commit

Permalink
fix(nitro): read firebase package.json (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Retsuki authored Oct 18, 2021
1 parent 5194af6 commit cc66a40
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit cc66a40

Please sign in to comment.