glob-stream icon indicating copy to clipboard operation
glob-stream copied to clipboard

File path after negative glob causes 'File not found with singular glob'

Open curvedriver opened this issue 1 year ago • 3 comments

What actually happened?

A ' File not found with singular glob' error will be thrown if a file path will be defined after a negative glob.

That's a regression to 6.1.0 and it seems that this issue is caused by the fact that anymatch#matchPatterns function just returns the index of the patterns array which does not include the negative patterns.

Therefore ourGlobs[matchIdx] returns the wrong glob.

  • https://github.com/micromatch/anymatch/blob/cbd278e43710eaf325d2061fa11aefd127c509be/index.js#L63
  • https://github.com/gulpjs/glob-stream/blob/77826594b4479fe5fefd6a751c28c7f686c24a87/index.js#L318C41-L319C1

Please give us a sample of your gulpfile

I added two tests at my fork: -https://github.com/curvedriver/glob-stream/pull/1/files

  1. file path before negative glob works as expected
  2. file path after negative glob throws the mentioned Error: File not found with singular glob:

See:

  • https://github.com/curvedriver/glob-stream/actions/runs/9661353317/job/26648885876

curvedriver avatar Jun 25 '24 11:06 curvedriver

Negative globs are now defined globally, not ordered. You can use ordered-read-stream to achieve similar behavior.

phated avatar Jun 25 '24 12:06 phated

Hi @phated ,

Thanks for quick response and the hint. I saw this in the changelogs and the corresponding PR before I created this issue.

With this change, glob-stream will no longer support ordered negation (each negative glob will apply to every positive glob)

I just want to make sure we're talking about the same because I still think that my reported issue is a bug.

Is it expected that a singular glob causes an error after a negative glob which doesn't match the same?

Just add e.g. /fixtures/test.coffee to the end of a globs list which contains a negative glob and you will receive the error. I did that at the following existing tests at my fork:

  • does not error when a negative glob removes all matches from a positive glob
  • applies all negative globs to each positive glob

See the related changes:

  • https://github.com/curvedriver/glob-stream/pull/1/files#diff-5bb8db779819ddef5956a5d9d5949c05ef7445237656ca37bf2f02720271440b

And the corresponding workflow run:

  • https://github.com/curvedriver/glob-stream/actions/runs/9675604314/job/26693442083

I can workaround that error when I define the single glob before the negative glob. As you can see at the prefixed "workaround - " tests in my fork, where I just moved the single glob to the first position.

  • https://github.com/curvedriver/glob-stream/pull/1/files#diff-5bb8db779819ddef5956a5d9d5949c05ef7445237656ca37bf2f02720271440b

curvedriver avatar Jun 26 '24 07:06 curvedriver

Re-opening so I remember to take a look at this later.

phated avatar Jun 01 '25 03:06 phated