Support negated pattern-list syntax in `fs.glob`
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 62/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript
調査の方向性
Issue に記載されている fs.glob および globSync API から始め、続いて提供されているパターン配列の例を実行して現在の動作を確認します。先頭が ! のエントリが一致を順番に削除し、後続の正のエントリがそれらを再度含め、options.exclude がグローバルな除外と callbacks に引き続き利用できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.4k
- 平均マージ
- 4日 4時間
- マージ済み PR(30日)
- 276
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nodejs/node のほかの issue
-
doc
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
build
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
似ている issue
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
githubnext/gh-aw-workshop#3692 ·
-
agent/guide documentation hive/hosted-available-lke648397-260827-5n31
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
Add: BuyPass TV オープンchannels:add check:passed
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
S: triage
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100