The script quoting behaviour introduced in #663 breaks package.json script entries with spaces in them on Unix.
Instead, this quotes node_modules/.bin executable paths, which makes sure both package.json script entries, and executables can be called.
For this package.json;
"test-help": "jest --help"
with dependencies installed,
yarn run test -- --help
yarn run test-help
yarn run jest -- --help
~/yarn test pr809
yarn run test --help
Note that the use of a help flag within a script is a contrived example, but triggers the incorrect behaviour in this case.
fixes #727, #733, #735 😄
Hi @ticky! Nice to see another Melburnian contributing to Yarn. I'm from Melbourne too 😄
For your test plan, I think it'd be good to include some examples of scripts that you tested with yarn run, and show the package.json you used. Yarn should handle both some sort of "global" command (eg. node foo.js, which runs node directly) as well as some local command (eg. jest foo-test.js when jest is listed as a devDependency in project.json but not installed globally, which runs node_modules\.bin\jest).
Maybe something like this:
"first": "node foo.js",
"second": "jest __tests__/hello-test.js"
Both yarn run first and yarn run second should work (assuming foo.js and __tests__/hello-test.js exist)
yarn run first
yarn run second
This is mainly so we can keep track of the test plan, and other people can re-test the exact same scenarios in the future if they're going to change the same code.
I suspect this will fix #735 too.
Just don’t tell anyone I actually started out in Perth 😜
I didn’t see anywhere in the existing test suite where this kind of CLI interop was tested, so I figured I’d leave adding such a thing to the repo proper for another intrepid soul.
Yarn does not currently run any executables on the system path; only executables within node_modules/.bin and package.json scripts, so the scenario you describe here in yarn run first isn’t applicable.
To that end, and given the current behaviour, I’ve updated the test scenarios in the PR description.
I'm adding tests for this in #821. I can't complete the tests right now because master is broken. If we can merge this I can continue with the tests.
@AlicanC if you take a look at the newly updated PR comment, it should lead you to six good test scenarios for this! 😄 I can’t really comment on how the test hooks in, as I’m not that familiar with this application of async stuff!
Fix executing scripts with spaces
The current build failure seems to be a flaky test 😉
Is running scripts with npm run still valid? Does it cooperate well with what yarn does?
Yarn puts executables in the same place npm is expecting them, so it works fine
i hope this will be merged soon as it effectively resolve this issue. Good job
Thank you so much!
@kittens Any ETA on a patch release that has this fix, or a way to workaround until then? (looks like there is a bunch of folks depending on this fix)
Thanks for the amazing work on yarn btw :)
@lfittl I've just been using npm run in the meantime and everything still works fine
or a way to workaround until then?
or a way to workaround until then?
If you like, you can clone the Yarn repository and build it to get all the latest bugfixes. Something like this should be sufficient on Linux (or Mac OS):
git clone git://github.com/yarnpkg/yarn.git
npm run build
Then add /usr/local/src/yarn/bin to your PATH, or use /usr/local/src/yarn/bin/yarn directly.
yarn run has troubles
probably bc of yarnpkg/yarn#809 so we'll run the npm scripts with npm for now
@Daniel15 npm link in yarn's source folder seems to DWIM and make yarn's git version available on npm's bin path.
When does this version get pushed as the latest release so I can get it with brew upgrade or with Ubuntu?
Currently having the same issue attempting to execute run script with yarn on Mac OS and Unix on CI. Do we know if this fix would be released as part of v0.15.2? (Currently using v0.15.1 at the time of this writing)
Having the same problem and posted a question about it. Looks like we just have to wait.
Just wanted to note that I don't see this issue when I install yarn via curl -o- -L https://yarnpkg.com/install.sh | bash so that might be another option while waiting for v0.15.2.
curl -o- -L https://yarnpkg.com/install.sh | bash
Thx @icd2k3, uninstalled yarn 0.15.1 (previously npm installed) and used the bash installer...
Everything is working now.
Still hitting this issue on my osx.
"start": "node server.js"
yarn run start
yarn run v0.15.1
$ "node server.js"
sh: node server.js: command not found
error Command failed with exit code 127.
Thanks @icd2k3 , it works!
Anyone have a rough ETA on when this will be released?
Anyone interested, please see #1156 for a work-around.