Skip to content

Commit

Permalink
COREPACK_ENABLE_UNSAFE_CUSTOM_URLS
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jan 30, 2024
1 parent d94fe5a commit a41e425
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ same major line. Should you need to upgrade to a new major, use an explicit
When standard input is a TTY and no CI environment is detected, Corepack will
ask for user input before starting the download.

- `COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM` can be set to `1` to allow use of
- `COREPACK_ENABLE_UNSAFE_CUSTOM_URLS` can be set to `1` to allow use of
custom URLs to load a package manager known by Corepack (`yarn`, `npm`, and
`pnpm`).

Expand Down
4 changes: 2 additions & 2 deletions sources/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ export class Engine {

async resolveDescriptor(descriptor: Descriptor, {allowTags = false, useCache = true}: {allowTags?: boolean, useCache?: boolean} = {}) {
if (!corepackUtils.isNotURLDescriptor(descriptor)) {
if (process.env.COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM !== `1` && isSupportedPackageManager(descriptor.name))
throw new UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM=1 in your environment (${descriptor.name}@${descriptor.range})`);
if (process.env.COREPACK_ENABLE_UNSAFE_CUSTOM_URLS !== `1` && isSupportedPackageManager(descriptor.name))
throw new UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_UNSAFE_CUSTOM_URLS=1 in your environment (${descriptor.name}@${descriptor.range})`);

return {
name: descriptor.name,
Expand Down
4 changes: 2 additions & 2 deletions sources/specUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export function parseSpec(raw: unknown, source: string, {enforceExactVersion = t
if (!isSupportedPackageManager(name)) {
throw new UsageError(`Unsupported package manager specification (${raw})`);
}
} else if (isSupportedPackageManager(name) && process.env.COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM !== `1`) {
throw new UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM=1 in your environment (${raw})`);
} else if (isSupportedPackageManager(name) && process.env.COREPACK_ENABLE_UNSAFE_CUSTOM_URLS !== `1`) {
throw new UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_UNSAFE_CUSTOM_URLS=1 in your environment (${raw})`);
}


Expand Down
2 changes: 1 addition & 1 deletion tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const testedPackageManagers: Array<[string, string] | [string, string, string]>
for (const [name, version, expectedVersion = version.split(`+`, 1)[0]] of testedPackageManagers) {
it(`should use the right package manager version for a given project (${name}@${version})`, async () => {
await xfs.mktempPromise(async cwd => {
const env = {...process.env, COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM: `1`};
const env = {...process.env, COREPACK_ENABLE_UNSAFE_CUSTOM_URLS: `1`};
await expect(runCli(cwd, [`${name}@${version}`, `--version`], {env})).resolves.toMatchObject({
exitCode: 0,
stderr: ``,
Expand Down

0 comments on commit a41e425

Please sign in to comment.