Skip to content

Commit

Permalink
fix(cli): fix --cwd (#1134)
Browse files Browse the repository at this point in the history
* fix(cli): fix --cwd

Fixes #1056.

* chore(release-workflow): set releases

* refactor(cli): make fix implementation use environment variables

* chore(release-workflow): update releases

* chore(release-workflow): fix releases
  • Loading branch information
paul-soporan committed Apr 3, 2020
1 parent 1d450d9 commit 31268cc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .yarn/versions/c0ece226.yml
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 5 additions & 0 deletions packages/gatsby/src/pages/configuration/yarnrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion packages/yarnpkg-cli/sources/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function runBinary(path: PortablePath) {
env: {
...process.env,
YARN_IGNORE_PATH: `1`,
YARN_IGNORE_CWD: `1`,
},
});
} else {
Expand All @@ -28,6 +29,7 @@ function runBinary(path: PortablePath) {
env: {
...process.env,
YARN_IGNORE_PATH: `1`,
YARN_IGNORE_CWD: `1`,
},
});
}
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions packages/yarnpkg-core/sources/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 31268cc

Please sign in to comment.