diff --git a/.yarn/versions/c0ece226.yml b/.yarn/versions/c0ece226.yml new file mode 100644 index 000000000000..2c14844d1fcc --- /dev/null +++ b/.yarn/versions/c0ece226.yml @@ -0,0 +1,29 @@ +releases: + "@yarnpkg/cli": prerelease + "@yarnpkg/core": prerelease + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-exec" + - "@yarnpkg/plugin-file" + - "@yarnpkg/plugin-git" + - "@yarnpkg/plugin-github" + - "@yarnpkg/plugin-http" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-link" + - "@yarnpkg/plugin-node-modules" + - "@yarnpkg/plugin-npm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/doctor" diff --git a/packages/gatsby/src/pages/configuration/yarnrc.json b/packages/gatsby/src/pages/configuration/yarnrc.json index 0bafa6e30ea7..93cacd7f84a4 100644 --- a/packages/gatsby/src/pages/configuration/yarnrc.json +++ b/packages/gatsby/src/pages/configuration/yarnrc.json @@ -136,6 +136,11 @@ "format": "uri", "default": "http://proxy:4040" }, + "ignoreCwd": { + "description": "If true, the `--cwd` flag will be ignored.", + "type": "boolean", + "default": false + }, "ignorePath": { "description": "If true, the local executable will be ignored when using the global one.", "type": "boolean", diff --git a/packages/yarnpkg-cli/sources/main.ts b/packages/yarnpkg-cli/sources/main.ts index cdf49f8e7599..67f4efa01f05 100644 --- a/packages/yarnpkg-cli/sources/main.ts +++ b/packages/yarnpkg-cli/sources/main.ts @@ -20,6 +20,7 @@ function runBinary(path: PortablePath) { env: { ...process.env, YARN_IGNORE_PATH: `1`, + YARN_IGNORE_CWD: `1`, }, }); } else { @@ -28,6 +29,7 @@ function runBinary(path: PortablePath) { env: { ...process.env, YARN_IGNORE_PATH: `1`, + YARN_IGNORE_CWD: `1`, }, }); } @@ -60,6 +62,7 @@ export async function main({binaryVersion, pluginConfiguration}: {binaryVersion: const yarnPath: PortablePath = configuration.get(`yarnPath`); const ignorePath = configuration.get(`ignorePath`); + const ignoreCwd = configuration.get(`ignoreCwd`); if (yarnPath !== null && !ignorePath) { if (!xfs.existsSync(yarnPath)) { @@ -85,7 +88,7 @@ export async function main({binaryVersion, pluginConfiguration}: {binaryVersion: // @ts-ignore: The cwd is a global option defined by BaseCommand const cwd: string | undefined = command.cwd; - if (typeof cwd !== `undefined`) { + if (typeof cwd !== `undefined` && !ignoreCwd) { const iAmHere = realpathSync(process.cwd()); const iShouldBeHere = realpathSync(cwd); diff --git a/packages/yarnpkg-core/sources/Configuration.ts b/packages/yarnpkg-core/sources/Configuration.ts index cb4102bfb62b..de7e528ba2c3 100644 --- a/packages/yarnpkg-core/sources/Configuration.ts +++ b/packages/yarnpkg-core/sources/Configuration.ts @@ -175,6 +175,11 @@ export const coreDefinitions: {[coreSettingName: string]: SettingsDefinition} = type: SettingsType.BOOLEAN, default: false, }, + ignoreCwd: { + description: `If true, the \`--cwd\` flag will be ignored`, + type: SettingsType.BOOLEAN, + default: false, + }, // Settings related to the package manager internal names globalFolder: {