mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-20 21:08:37 -05:00
* fix(patch): saved path file should be relative path * fix: update relative dir * fix: update * fix: paths in patchedDependencies should be normalized --------- Co-authored-by: Zoltan Kochan <z@kochan.io>
23 lines
809 B
TypeScript
23 lines
809 B
TypeScript
import path from 'path'
|
|
import normalizePath from 'normalize-path'
|
|
import { writeSettings, type WriteSettingsOptions } from '@pnpm/config.config-writer'
|
|
|
|
export async function updatePatchedDependencies (
|
|
patchedDependencies: Record<string, string>,
|
|
opts: Omit<WriteSettingsOptions, 'updatedSettings'>
|
|
): Promise<void> {
|
|
const workspaceDir = opts.workspaceDir ?? opts.rootProjectManifestDir
|
|
for (const [patchName, patchPath] of Object.entries(patchedDependencies)) {
|
|
if (path.isAbsolute(patchPath)) {
|
|
patchedDependencies[patchName] = normalizePath(path.relative(workspaceDir, patchPath))
|
|
}
|
|
}
|
|
await writeSettings({
|
|
...opts,
|
|
workspaceDir,
|
|
updatedSettings: {
|
|
patchedDependencies: Object.keys(patchedDependencies).length ? patchedDependencies : undefined,
|
|
},
|
|
})
|
|
}
|