Skip to content

Commit

Permalink
FEAT: simplify appLockFile handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maman authored Dec 5, 2021
1 parent d28b55a commit b4dad0b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/getPackageResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ export function getPackageResolution({
const lockFileString = readFileSync(lockFilePath).toString()
let appLockFile
if (lockFileString.includes("yarn lockfile v1")) {
appLockFile = parseYarnLockFile(lockFileString)
if (appLockFile.type !== "success") {
const parsedYarnLockFile = parseYarnLockFile(lockFileString)
if (parsedYarnLockFile.type !== "success") {
throw new Error("Can't parse lock file")
} else {
appLockFile = parsedYarnLockFile.object
}
} else {
try {
Expand All @@ -48,7 +50,7 @@ export function getPackageResolution({
join(resolve(appPath, packageDetails.path), "package.json"),
)

const entries = Object.entries(appLockFile.object || appLockFile).filter(
const entries = Object.entries(appLockFile).filter(
([k, v]) =>
k.startsWith(packageDetails.name + "@") &&
// @ts-ignore
Expand Down

0 comments on commit b4dad0b

Please sign in to comment.