[Bug] `--cwd` gets ignored when specified inside package.json script
See original GitHub issue- I’d be willing to implement a fix
Describe the bug
{
"scripts": {
"foo": "yarn --cwd .yarn exec cd"
}
}
Running yarn foo
prints out the current path, not .yarn
as specified in --cwd
.
Running yarn --cwd .yarn exec cd
directly in the shell produces the correct output.
To Reproduce
Use the following package.json
{
"name": "foo",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"foo": "yarn --cwd .yarn exec cd"
}
}
Run yarn foo
from the package directorty.
Environment if relevant
- OS: Windows 10 v2004
- Node version: 12.13.1
- Yarn version: 2.4.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (4 by maintainers)
Top Results From Across the Web
npm - run scripts in directory other than cwd - Stack Overflow
However it seems the first cd command is being ignored; the subsequent commands are being executed in the parent, not child, directory. I've ......
Read more >Configuration options | Yarn - Package Manager
Files matching the following patterns (in terms of relative paths compared to the root of the project) will be ignored by the yarn...
Read more >Configuration Files - ESLint - Pluggable JavaScript Linter
JavaScript (ESM) - use .eslintrc.cjs when running ESLint in JavaScript packages that specify "type":"module" in their package.json . Note that ESLint does ...
Read more >Configure Babel
babelrc documentation to see more configuration options. package.json. Alternatively, you can choose to specify your .babelrc.json config from within ...
Read more >npm-check-updates
npm-check-updates upgrades your package.json dependencies to the latest versions, ignoring specified versions.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is a valid issue, you’re running into https://github.com/yarnpkg/berry/pull/1812#discussion_r485873759, as a workaround you can specify the path as the first argument
I don’t think
--cwd
is doing anything at all (inside or outside of package.json). It can be confirmed with a simpleyarn --cwd /expected exec pwd
. Output would be anything but/expected
. What exactly--cwd
is supposed to be doing?