Skip to content

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

@outslept

Description

@outslept

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamNeeds work upstream

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions