Skip to content

Commit 0727cf9

Browse files
authored
feat(config): add helper for loading kit config in the case where package.json has been parsed already (#3492)
* add helper for loading kit config when package.json has already been parsed * docs(changeset): Add helper to load the kit config from an already parsed package.json file * add export for new helper (missed when xferring change over) * renamed getKitConfigFromPackageJson to getKitConfigFromPackageManifest
1 parent d60608a commit 0727cf9

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.changeset/cuddly-carrots-carry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rnx-kit/config": patch
3+
---
4+
5+
Add helper to load the kit config from an already parsed package.json file

packages/config/src/getKitConfig.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,16 @@ export function getKitConfig(
6969
return undefined;
7070
}
7171
}
72+
73+
/**
74+
* Helper for loading the KitConfig for cases where the package.json has already been loaded for other reasons.
75+
* @param packageJson The loaded and parsed package.json file for this package.
76+
* @param packageDir The directory containing the package.json file.
77+
* @returns The rnx-kit configuration for this package, merged with any base configuration.
78+
*/
79+
export function getKitConfigFromPackageManifest(
80+
packageJson: PackageManifest,
81+
packageDir: string
82+
): KitConfig | undefined {
83+
return loadBaseConfig(packageJson["rnx-kit"], packageDir);
84+
}

packages/config/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export { getBundleConfig, getPlatformBundleConfig } from "./getBundleConfig";
1111
export { getKitCapabilities } from "./getKitCapabilities";
1212
export type { KitCapabilities } from "./getKitCapabilities";
1313

14-
export { getKitConfig } from "./getKitConfig";
14+
export { getKitConfig, getKitConfigFromPackageManifest } from "./getKitConfig";
1515
export type { GetKitConfigOptions } from "./getKitConfig";
1616

1717
export type {

0 commit comments

Comments
 (0)