tinyglobby icon indicating copy to clipboard operation
tinyglobby copied to clipboard

Brace expansion `{01..03}`, `{1..5..2}`, `{c..a}` patterns fail

Open outslept opened this issue 5 months ago • 1 comments

picomatch has weird range support, some work, some don't

what I've observed during testing:

1.zero-padded range don't work

import { glob } from 'tinyglobby';
import { writeFileSync, unlinkSync } from 'fs';

writeFileSync('file01.txt', '');
console.log(await glob('file{01..03}.txt')); // [] - should be ['file01.txt']
unlinkSync('file01.txt');
  1. step ranges include wrong files
writeFileSync('file1.txt', '');
writeFileSync('file2.txt', '');
writeFileSync('file3.txt', '');
writeFileSync('file5.txt', '');

console.log(await glob('file{1..5..2}.txt')); 
// ['file1.txt', 'file2.txt', 'file5.txt'] - should be ['file1.txt', 'file3.txt', 'file5.txt']

['file1.txt', 'file2.txt', 'file3.txt', 'file5.txt'].forEach(f => unlinkSync(f));
  1. reverse ranges ignore order
writeFileSync('a.js', '');
writeFileSync('b.js', '');
writeFileSync('c.js', '');

console.log(await glob('{c..a}.js'));
// ['a.js', 'b.js', 'c.js'] - should be ['c.js', 'b.js', 'a.js']

['a.js', 'b.js', 'c.js'].forEach(f => unlinkSync(f));

haven't seen patterns like №3 used much in the wild. it's upstream, but might be worth documenting as a known limitation since you're working on the website

p.s. mostly doing this for search visibility.

outslept avatar Jul 18 '25 20:07 outslept

yeah this is sadly not possible unless we provide our own brace expansion function to picomatch i think. thankfully it looks like usage of this is extremely rare. will be nice to document on the upcoming website yes

SuperchupuDev avatar Jul 18 '25 21:07 SuperchupuDev