Skip to content
This repository was archived by the owner on Dec 4, 2022. It is now read-only.

Commit fa222f8

Browse files
committed
fix tests
1 parent 0c28bfa commit fa222f8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/dependency-builder/build-tree.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ export function resolveNodePackage(cwd: string, packageFullPath: string): Record
8383
// we will look for the package.json on the dependency but won't find it
8484
// if we propagate we will take the version from the root's package json which has nothing with the component version
8585
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
86-
const packageInfo = PackageJson.loadSync(packageDir, false);
86+
const packageInfo = PackageJson.getPackageJsonSync(packageDir);
8787

8888
// when running 'bitjs get-dependencies' command, packageInfo is sometimes empty
8989
// or when using custom-module-resolution it may be empty or the name/version are empty
9090
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
9191
if (!packageInfo || !packageInfo.name || !packageInfo.version) return null;
92+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
9293
result[packageInfo.name] = packageInfo.version;
9394
return result;
9495
}

src/package-json/package-json.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ export default class PackageJson {
7272
return null;
7373
}
7474

75+
/*
76+
* load package.json from path
77+
*/
78+
static async getPackageJsonSync(pathStr: string) {
79+
const getRawObject = () => fs.readJsonSync(composePath(pathStr));
80+
const exist = PackageJson.hasExisting(pathStr);
81+
if (exist) return getRawObject();
82+
return null;
83+
}
84+
7585
/*
7686
* save package.json in path
7787
*/

0 commit comments

Comments
 (0)