-
-
Notifications
You must be signed in to change notification settings - Fork 936
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(patch): allow to edit a package in any directory (#5331)
- Loading branch information
Showing
5 changed files
with
77 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@pnpm/plugin-commands-patching": patch | ||
"pnpm": patch | ||
--- | ||
|
||
Fix `pnpm patch` using a custom `--edit-dir`. |
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,29 @@ | ||
import { Config } from '@pnpm/config' | ||
import { | ||
createOrConnectStoreController, | ||
CreateStoreControllerOptions, | ||
} from '@pnpm/store-connection-manager' | ||
import pickRegistryForPackage from '@pnpm/pick-registry-for-package' | ||
import parseWantedDependency from '@pnpm/parse-wanted-dependency' | ||
|
||
export type WritePackageOptions = CreateStoreControllerOptions & Pick<Config, 'registries'> | ||
|
||
export async function writePackage (pkg: string, dest: string, opts: WritePackageOptions) { | ||
const dep = parseWantedDependency(pkg) | ||
const store = await createOrConnectStoreController({ | ||
...opts, | ||
packageImportMethod: 'clone-or-copy', | ||
}) | ||
const pkgResponse = await store.ctrl.requestPackage(dep, { | ||
downloadPriority: 1, | ||
lockfileDir: opts.dir, | ||
preferredVersions: {}, | ||
projectDir: opts.dir, | ||
registry: (dep.alias && pickRegistryForPackage(opts.registries, dep.alias)) ?? opts.registries.default, | ||
}) | ||
const filesResponse = await pkgResponse.files!() | ||
await store.ctrl.importPackage(dest, { | ||
filesResponse, | ||
force: true, | ||
}) | ||
} |
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