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

Glob pattern does not work on windows #607

Closed
aeneasr opened this issue Nov 20, 2016 · 5 comments
Closed

Glob pattern does not work on windows #607

aeneasr opened this issue Nov 20, 2016 · 5 comments

Comments

@aeneasr
Copy link

aeneasr commented Nov 20, 2016

documentation build ./src/editor/**/*.js --format md --github -o docs/API.md

results in

Input file ./src/editor/**/*.js not found!

on windows, but works as expected on linux/osx

@tmcw
Copy link
Member

tmcw commented Nov 21, 2016

Thanks for the report. This was previously discussed in #335

I'm not sure what to do in this case. Globs are a console feature, not a documentation.js feature. When you say documentation build ./src/editor/**/*.js, documentation receives that as documentation build ./src/editor/dir/file.js ./src/editor/dir/other-file.js: it doesn't do glob expansion.

Are you using Windows PowerShell or another type of shell in Windows? PowerShell should support globs as wikipedia says.

There are multiple possible actionables here:

  • If Windows supports globs but with different syntax, we can document and link that syntax
  • If this is truly essential, we can expand globs in documentation.js. I'm cautious to do this: this would break glob features in other systems and mean that we're targeting Windows. My previous efforts to target Windows have been unsuccessful because I never found a reliable way to continuously test Windows (I don't use Windows and none of our current core contributors do either). I will not introduce any Windows-specific workarounds with continuous integration tests.

@aeneasr
Copy link
Author

aeneasr commented Nov 21, 2016

Ah, sorry for the duplicate! How about using something like https://github.com/isaacs/node-glob in documentation.js?

@tmcw
Copy link
Member

tmcw commented Dec 9, 2016

Looking into the glob implementation here, but can you confirm which shell you're using in Windows? PowerShell should have support, as should cygwin.

This is troubling to me because of this case:

  • You're on a Linux or OSX system, using a shell with glob expansion
  • You have a file named foo*bar and a file named foobazbar
  • You run documentation build foo\*bar in a shell
  • node receives argv = ['foo*bar']
  • Now the behavior diverges whether I implement this feature
    • If we expand globs, then you get foo*bar and foobazbar
    • If we don't (as the behavior is currently), you get foo*bar

The problem here is:

  • Unix systems escape input like foo\*bar to foo*bar in argv[2]
  • Windows systems would also give you foo*bar and you'd want to expand that

Illustrative example:

test.js:

console.log(process.argv.slice(2));

output:

~/src/documentation〉node test foo\*bar
[ 'foo*bar' ]
~/src/documentation〉node test foo*bar
[ 'foo*bar', 'foobazbar' ]

So, implementing glob on all input naively would change OSX/Linux behavior in a way that makes it less precise: it would no longer be able to specify files that look like globs without expanding them as globs.

Very interested in if anyone has solutions here, of can write documentation for people to use Windows glob patterns to dodge this problem.

tmcw added a commit that referenced this issue Dec 9, 2016
This brings logic from eslint over to documentation: instead of readdirSync, we're using the glob

module. This also, I hope, will let us support globs on Windows without changing OSX/Linux behavior.

Fixes #607
@tmcw
Copy link
Member

tmcw commented Dec 9, 2016

eslint actually does this 🙌 , praise eslint!

The trick is:

  • For every input eslint sees, before expanding the glob it checks that the input is not a file with shelljs.

The magic is in https://github.com/eslint/eslint/blob/master/lib/util/glob-util.js

Got an initial port of the eslint logic at #629

@rowanwins
Copy link

Gday @tmcw

Just confirming that the glob issue does occur on windows even when using powershell.

I'll keep an eye on the issue and your pull request as am currently looking at tidying up the turf docs but I currently can't do anything with them :(

tmcw added a commit that referenced this issue Dec 17, 2016
This brings logic from eslint over to documentation: instead of readdirSync, we're using the glob
module. This also, I hope, will let us support globs on Windows without changing OSX/Linux behavior.
Fixes #607
tmcw added a commit that referenced this issue Dec 26, 2016
This brings logic from eslint over to documentation: instead of readdirSync, we're using the glob
module. This also, I hope, will let us support globs on Windows without changing OSX/Linux behavior.
Fixes #607
tmcw added a commit that referenced this issue Dec 26, 2016
This brings logic from eslint over to documentation: instead of readdirSync, we're using the glob
module. This also, I hope, will let us support globs on Windows without changing OSX/Linux behavior.
Fixes #607
@tmcw tmcw closed this as completed in #629 Dec 26, 2016
tmcw added a commit that referenced this issue Dec 26, 2016
This brings logic from eslint over to documentation: instead of readdirSync, we're using the glob
module. This also, I hope, will let us support globs on Windows without changing OSX/Linux behavior.
Fixes #607
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

3 participants