Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
feat(pkgmap): cache pkgmaps even if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Aug 8, 2018
1 parent 7066961 commit 3cfd0e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/pkgmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ function resolve (...p) {
const pkgMapIdx = resolved.indexOf(pkgMapName)
if (pkgMapIdx !== -1 && pkgMapIdx + mapNameLen < resolved.length) {
const pkgMapPath = resolved.substr(0, pkgMapIdx + mapNameLen)
let pkgMap = pkgMapCache.get(pkgMapPath)
if (!pkgMap) {
let pkgMap
if (pkgMapCache.has(pkgMapPath)) {
pkgMap = pkgMapCache.get(pkgMapPath)
} else {
try {
const p = path.toNamespacedPath(pkgMapPath)
pkgMap = JSON.parse(fs.readFileSync(p))
pkgMapCache.set(p, pkgMap)
} catch (err) {
return null
return false
}
}
if (!pkgMap) { return false }
let subPath = resolved.substr(pkgMapIdx + mapNameLen + 1)
let pkgName
let scope = pkgMap
Expand Down

0 comments on commit 3cfd0e6

Please sign in to comment.