Skip to content

Commit

Permalink
feat(config): add helper for loading kit config in the case where pac…
Browse files Browse the repository at this point in the history
…kage.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
  • Loading branch information
JasonVMo authored Jan 23, 2025
1 parent d60608a commit 0727cf9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/cuddly-carrots-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnx-kit/config": patch
---

Add helper to load the kit config from an already parsed package.json file
13 changes: 13 additions & 0 deletions packages/config/src/getKitConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,16 @@ export function getKitConfig(
return undefined;
}
}

/**
* Helper for loading the KitConfig for cases where the package.json has already been loaded for other reasons.
* @param packageJson The loaded and parsed package.json file for this package.
* @param packageDir The directory containing the package.json file.
* @returns The rnx-kit configuration for this package, merged with any base configuration.
*/
export function getKitConfigFromPackageManifest(
packageJson: PackageManifest,
packageDir: string
): KitConfig | undefined {
return loadBaseConfig(packageJson["rnx-kit"], packageDir);
}
2 changes: 1 addition & 1 deletion packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export { getBundleConfig, getPlatformBundleConfig } from "./getBundleConfig";
export { getKitCapabilities } from "./getKitCapabilities";
export type { KitCapabilities } from "./getKitCapabilities";

export { getKitConfig } from "./getKitConfig";
export { getKitConfig, getKitConfigFromPackageManifest } from "./getKitConfig";
export type { GetKitConfigOptions } from "./getKitConfig";

export type {
Expand Down

0 comments on commit 0727cf9

Please sign in to comment.