-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt pnpm overrides from root package manifest (#62)
- Loading branch information
Showing
3 changed files
with
51 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { ProjectManifest } from "@pnpm/types"; | ||
import path from "path"; | ||
import type { PackageManifest } from "~/lib/types"; | ||
import { readTypedJson } from "~/lib/utils"; | ||
|
||
/** | ||
* Adopts the `pnpm` fields from the root package manifest. Currently it only | ||
* takes overrides, because I don't know if any of the others are useful or | ||
* desired. | ||
*/ | ||
export async function adoptPnpmFieldsFromRoot( | ||
targetPackageManifest: PackageManifest, | ||
workspaceRootDir: string | ||
) { | ||
const rootPackageManifest = await readTypedJson<ProjectManifest>( | ||
path.join(workspaceRootDir, "package.json") | ||
); | ||
|
||
const overrides = rootPackageManifest.pnpm?.overrides; | ||
|
||
if (!overrides) { | ||
return targetPackageManifest; | ||
} | ||
|
||
return { | ||
...targetPackageManifest, | ||
pnpm: { | ||
overrides, | ||
}, | ||
}; | ||
} |