Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globs are handled differently #4118

Closed
edgarjs opened this issue Aug 8, 2017 · 5 comments
Closed

globs are handled differently #4118

edgarjs opened this issue Aug 8, 2017 · 5 comments

Comments

@edgarjs
Copy link

edgarjs commented Aug 8, 2017

Do you want to request a feature or report a bug?

  • Bug

What is the current behavior?

  • My test command declared in package.json is NODE_ENV=test mocha --compilers js:babel-register --recursive ./test/**/*.test.js; which if a run directly, it runs the tests for all my files including one directly under ./test/digestor.test.js, but when I run it via yarn test, it only executes the test files that are at a second level of depth (in other words, it doesn't run ./test/digestor.test.js).

If the current behavior is a bug, please provide the steps to reproduce.

  1. Clone repository at https://github.com/edgarjs/yarn-bug
  2. Install the dependencies.
  3. Run yarn test and see results.
  4. Run NODE_ENV=test mocha --compilers js:babel-register --recursive ./test/**/*.test.js and compare results from step 3.

What is the expected behavior?
Step 3 should run the same tests as step 4.

Please mention your node.js, yarn and operating system version.
OS: macOS Sierra 10.12.6
Node: 6.11.1
Yarn: 0.27.5


yarn-bug 2017-08-08 3hnqr

@edgarjs edgarjs changed the title globs do not return the same as shell globs are handled differently Aug 8, 2017
@mitermayer
Copy link

mitermayer commented Sep 14, 2017

looks like yarn is not respecting the globstar flag. @edgarjs in the meantime you can do this workaround on your package.json

  "scripts": {
     "foo":  "shopt -s globstar && someCommand **/src/**/*.js",
  }

@BYK
Copy link
Member

BYK commented Sep 14, 2017

Yarn doesn't do anything with globs at all. It simply passes these to bin/sh on Unix systems. Either you had a global mocha installed which was supporting globstar where as your package-specific mocha was not supporting it, or sh/bash was not handling globstar properly.

We've changed the way we invoke scripts slightly so you may wanna give 1.0.2 a shot to see if it fixes your issue. If it doesn't I'd try running the following to see if all behave the same way:

NODE_ENV=test mocha --compilers js:babel-register --recursive ./test/**/*.test.js
NODE_ENV=test yarn mocha --compilers js:babel-register --recursive ./test/**/*.test.js
NODE_ENV=test ./node_modues/.bin/mocha --compilers js:babel-register --recursive ./test/**/*.test.js

@rally25rs
Copy link
Contributor

rally25rs commented Feb 16, 2018

You are probably using zsh, aren't you? zsh uses different globbing rules than standard sh, and by default npm and yarn spawn commands in sh

there is some info in this blog post: https://medium.com/@jakubsynowiec/you-should-always-quote-your-globs-in-npm-scripts-621887a2a784

@edgarjs
Copy link
Author

edgarjs commented Feb 19, 2018 via email

@rally25rs
Copy link
Contributor

Going to close this as it's a shell implementation difference (zsh vs sh).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants