Skip to content

Commit b4dad0b

Browse files
authored
FEAT: simplify appLockFile handling
1 parent d28b55a commit b4dad0b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/getPackageResolution.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ export function getPackageResolution({
3131
const lockFileString = readFileSync(lockFilePath).toString()
3232
let appLockFile
3333
if (lockFileString.includes("yarn lockfile v1")) {
34-
appLockFile = parseYarnLockFile(lockFileString)
35-
if (appLockFile.type !== "success") {
34+
const parsedYarnLockFile = parseYarnLockFile(lockFileString)
35+
if (parsedYarnLockFile.type !== "success") {
3636
throw new Error("Can't parse lock file")
37+
} else {
38+
appLockFile = parsedYarnLockFile.object
3739
}
3840
} else {
3941
try {
@@ -48,7 +50,7 @@ export function getPackageResolution({
4850
join(resolve(appPath, packageDetails.path), "package.json"),
4951
)
5052

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

0 commit comments

Comments
 (0)