Support negated pattern-list syntax in `fs.glob`
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
What problem would this feature solve?
Node's fs.glob() accepts an array of patterns, but entries beginning with ! are not interpreted as exclusions:
globSync([
'src/**/*.js',
'!src/generated/**',
]);
Node.js does support negative extglobs such as !(pattern), but that is a different feature. An extglob negates part of a single pattern while negated pattern-list syntax applies an exclusion to the matches (based on other entries in the array).
Node.js also provides options.exclude, but it cannot fully represent ordered pattern lists where a later positive pattern re-includes a path.
Ecosystem
Leading-! entries are supported by packages such as globby and tinyglobby:
await globby(['src/**/*.js', '!src/generated/**']);
await glob(['src/**/*.js', '!src/generated/**']); // tinyglobby
Supporting this syntax would make migration to the built-in API easier and allow existing pattern arrays from configuration files and CLI arguments to be reused unchanged.
What feature are you proposing?
When pattern is an array, interpret entries beginning with ! as negated pattern-list entries:
globSync([
'src/**/*.js',
'!src/generated/**',
]);
Patterns should be processed in order:
- A positive pattern adds matching paths.
- A negated pattern removes matching paths.
- A later positive pattern can re-include previously removed paths.
For example:
globSync([
'src/**/*.js',
'!src/generated/**',
'src/generated/keep.js',
]);
This should include src/generated/keep.js.
The existing options.exclude API should remain available for global exclusions and exclusion callbacks.
What alternatives have you considered?
Applications can split positive and negative entries:
globSync(include, { exclude });
However, this loses ordering semantics and cannot represent later re-inclusion without additional processing.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con le API fs.glob e globSync descritte nell’issue, quindi esegui gli esempi forniti di array di pattern per stabilire il comportamento attuale. Il lavoro è completato quando le voci con ! iniziale rimuovono le corrispondenze in ordine, le voci positive successive le includono nuovamente e options.exclude rimane disponibile per le esclusioni globali e i callback.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- operating-systems
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 62/100