micromatch / braces

Faster brace expansion for node.js. Besides being faster, braces is not subject to DoS attacks like minimatch, is more accurate, and has more complete support for Bash 4.3.
https://github.com/jonschlinkert
MIT License
207 stars 47 forks source link

Expand-braces test cases failed when upgrading braces from v1.8.5 to v2.3.2 #21

Closed Teamop closed 5 years ago

Teamop commented 5 years ago

First, Travis log from micromatch/expand-braces#2

 1) given an array of patterns with braces
       braces
         should work with one value:
      AssertionError: expected [ 'a{b}c', 'a/b/c{d}e' ] to equal [ 'abc', 'a/b/cde' ] (at '0', A has 'a{b}c' and B has 'abc')
      + expected - actual
       [
      -  "a{b}c"
      -  "a/b/c{d}e"
      +  "abc"
      +  "a/b/cde"
       ]

      at Proxy.fail (node_modules/should/lib/assertion.js:228:17)
      at Proxy.prop.(anonymous function) (node_modules/should/lib/assertion.js:69:14)
      at Context.<anonymous> (test.js:32:45)
  2) given an array of patterns with braces
       braces
         should work with nested non-sets:
      AssertionError: expected [ '{a-b}', '{a-c}', '{a-d}', 'a' ] to equal [ 'a-b', 'a-c', 'a-d', 'a' ] (at '0', A has '{a-b}' and B has 'a-b')
      + expected - actual
       [
      -  "{a-b}"
      -  "{a-c}"
      -  "{a-d}"
      +  "a-b"
      +  "a-c"
      +  "a-d"
         "a"
       ]

      at Proxy.fail (node_modules/should/lib/assertion.js:228:17)
      at Proxy.prop.(anonymous function) (node_modules/should/lib/assertion.js:69:14)
      at Context.<anonymous> (test.js:36:57)
  3) given an array of patterns with braces
       braces
         should expand sets:
      AssertionError: expected [ 'a/x/c{d}e', 'a/y/c{d}e', 'a/b/c/x', 'a/b/c/y' ] to equal [ 'a/x/cde', 'a/y/cde', 'a/b/c/x', 'a/b/c/y' ] (at '0', A has 'a/x/c{d}e' and B has 'a/x/cde')
      + expected - actual
       [
      -  "a/x/c{d}e"
      -  "a/y/c{d}e"
      +  "a/x/cde"
      +  "a/y/cde"
         "a/b/c/x"
         "a/b/c/y"
       ]

      at Proxy.fail (node_modules/should/lib/assertion.js:228:17)
      at Proxy.prop.(anonymous function) (node_modules/should/lib/assertion.js:69:14)
      at Context.<anonymous> (test.js:44:55)
  4) given an array of patterns with braces
       braces
         should throw an error when imbalanced braces are found.:
     AssertionError: expected [Function] to throw exception
      at Proxy.fail (node_modules/should/lib/assertion.js:228:17)
      at Proxy.prop.(anonymous function) (node_modules/should/lib/assertion.js:69:14)
      at Context.<anonymous> (test.js:50:22)
  5) given an array of patterns with braces
       should expand a combination of nested sets and ranges.
         should expand sets:
      AssertionError: expected [
  'a/x/c{d}e',
  'a/1/c{d}e',
  'a/2/c{d}e',
  'a/3/c{d}e',
  'a/4/c{d}e',
  'a/5/c{d}e',
  'a/y/c{d}e'
] to equal [
  'a/x/cde',
  'a/1/cde',
  'a/y/cde',
  'a/2/cde',
  'a/3/cde',
  'a/4/cde',
  'a/5/cde'
] (at '0', A has 'a/x/c{d}e' and B has 'a/x/cde')
      + expected - actual
       [
      -  "a/x/c{d}e"
      -  "a/1/c{d}e"
      -  "a/2/c{d}e"
      -  "a/3/c{d}e"
      -  "a/4/c{d}e"
      -  "a/5/c{d}e"
      -  "a/y/c{d}e"
      +  "a/x/cde"
      +  "a/1/cde"
      +  "a/y/cde"
      +  "a/2/cde"
      +  "a/3/cde"
      +  "a/4/cde"
      +  "a/5/cde"
       ]

      at Proxy.fail (node_modules/should/lib/assertion.js:228:17)
      at Proxy.prop.(anonymous function) (node_modules/should/lib/assertion.js:69:14)
      at Context.<anonymous> (test.js:85:47)

I think for braces expand with single item, in v 1.8.5, default is

braces('a{b}c');
//=> ['abc']

in v2.3.2, the default

console.log(braces.expand('a{b}c'));
//=> ['a{b}c']

That's the reason why the cases failed

but @jonschlinkert said that this is unrelated, so could you elaborate a bit? thanks

Teamop commented 5 years ago

According to the recent update in micromatch/expand-braces#2, it's because the cases are wrong, but do you think if it's worth to provide a way for backwards compatibility? seems a lot of packages depends on it.

jonschlinkert commented 5 years ago

do you think if it's worth to provide a way for backwards compatibility? seems a lot of packages depends on it.

I think we'll always be better off staying as close to established conventions as possible. IMHO you can easily get around the "issue" by designing your brace pattern differently.