|
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'; |
7 | 7 |
|
8 | | -import {pluginCommands} from './pluginCommands'; |
| 8 | +import {pluginCommands} from './pluginCommands'; |
9 | 9 |
|
10 | 10 | function runBinary(path: PortablePath) { |
11 | 11 | const physicalPath = npath.fromPortablePath(path); |
@@ -60,7 +60,11 @@ export async function main({binaryVersion, pluginConfiguration}: {binaryVersion: |
60 | 60 | const version = process.versions.node; |
61 | 61 | const range = `>=12 <14 || 14.2 - 14.9 || >14.10.0`; |
62 | 62 |
|
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)) |
64 | 68 | 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.`); |
65 | 69 |
|
66 | 70 | // Since we only care about a few very specific settings (yarn-path and ignore-path) we tolerate extra configuration key. |
|
0 commit comments