Skip to content

Commit d64baeb

Browse files
authored
fix: use parseOptionalBoolean on YARN_IGNORE_NODE (#4052)
* fix: use parseOptionalBoolean on YARN_IGNORE_NODE * chore: add comment * chore: versions * chore: changelog
1 parent d4968ad commit d64baeb

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

.yarn/versions/a1a4200d.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
4+
declined:
5+
- "@yarnpkg/plugin-compat"
6+
- "@yarnpkg/plugin-constraints"
7+
- "@yarnpkg/plugin-dlx"
8+
- "@yarnpkg/plugin-essentials"
9+
- "@yarnpkg/plugin-init"
10+
- "@yarnpkg/plugin-interactive-tools"
11+
- "@yarnpkg/plugin-nm"
12+
- "@yarnpkg/plugin-npm-cli"
13+
- "@yarnpkg/plugin-pack"
14+
- "@yarnpkg/plugin-patch"
15+
- "@yarnpkg/plugin-pnp"
16+
- "@yarnpkg/plugin-pnpm"
17+
- "@yarnpkg/plugin-stage"
18+
- "@yarnpkg/plugin-typescript"
19+
- "@yarnpkg/plugin-version"
20+
- "@yarnpkg/plugin-workspace-tools"
21+
- "@yarnpkg/builder"
22+
- "@yarnpkg/core"
23+
- "@yarnpkg/doctor"

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Various improvements have been made in the core to improve performance. Addition
5858
- Fixed a crash caused by a bad interaction between aliased packages and peer dependencies.
5959
- The ESBuild plugin will no longer allow access to Node.js builtins if the `platform` isn't set to Node.
6060
- SemVer ranges with build metadata can now be resolved.
61+
- The `YARN_IGNORE_NODE` environment variable will now be parsed using the same mechanism as env variable configuration settings (i.e. both `1`/`0` and `true`/`false` will be accepted)
6162

6263
### ZipFS Extension
6364

packages/yarnpkg-cli/sources/main.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {Configuration, CommandContext, PluginConfiguration, TelemetryManager, semverUtils} from '@yarnpkg/core';
2-
import {PortablePath, npath, xfs} from '@yarnpkg/fslib';
3-
import {execFileSync} from 'child_process';
4-
import {isCI} from 'ci-info';
5-
import {Cli, UsageError} from 'clipanion';
6-
import {realpathSync} from 'fs';
1+
import {Configuration, CommandContext, PluginConfiguration, TelemetryManager, semverUtils, miscUtils} from '@yarnpkg/core';
2+
import {PortablePath, npath, xfs} from '@yarnpkg/fslib';
3+
import {execFileSync} from 'child_process';
4+
import {isCI} from 'ci-info';
5+
import {Cli, UsageError} from 'clipanion';
6+
import {realpathSync} from 'fs';
77

8-
import {pluginCommands} from './pluginCommands';
8+
import {pluginCommands} from './pluginCommands';
99

1010
function runBinary(path: PortablePath) {
1111
const physicalPath = npath.fromPortablePath(path);
@@ -60,7 +60,11 @@ export async function main({binaryVersion, pluginConfiguration}: {binaryVersion:
6060
const version = process.versions.node;
6161
const range = `>=12 <14 || 14.2 - 14.9 || >14.10.0`;
6262

63-
if (process.env.YARN_IGNORE_NODE !== `1` && !semverUtils.satisfiesWithPrereleases(version, range))
63+
// YARN_IGNORE_NODE is special because this code needs to execute as early as possible.
64+
// It's not a regular core setting because Configuration.find may use functions not available
65+
// on older Node versions.
66+
const ignoreNode = miscUtils.parseOptionalBoolean(process.env.YARN_IGNORE_NODE);
67+
if (!ignoreNode && !semverUtils.satisfiesWithPrereleases(version, range))
6468
throw new UsageError(`This tool requires a Node version compatible with ${range} (got ${version}). Upgrade Node, or set \`YARN_IGNORE_NODE=1\` in your environment.`);
6569

6670
// Since we only care about a few very specific settings (yarn-path and ignore-path) we tolerate extra configuration key.

0 commit comments

Comments
 (0)