Skip to content

Glob pattern does not work on windows #607

Closed

Description

@aeneasr
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

Activity

  1. tmcw commented on Nov 21, 2016

    @tmcw
    Member

    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.
  2. aeneasr commented on Nov 21, 2016

    @aeneasr
    Author

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

  3. tmcw commented on Dec 9, 2016

    @tmcw
    Member

    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.

  4. added a commit that references this issue on Dec 9, 2016
    9f2a3d7
  5. tmcw commented on Dec 9, 2016

    @tmcw
    Member

    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

  6. rowanwins commented on Dec 12, 2016

    @rowanwins

    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 :(

  7. added a commit that references this issue on Dec 17, 2016
    79f8b90
  8. added 2 commits that reference this issue on Dec 26, 2016
    0486223
    986be00
  9. added a commit that references this issue on Dec 26, 2016
    cb8fdfa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions