ProjectEvergreen/greenwood

refactor usages of glob-promise with native NodeJS `fs.glob`

オープン

#1,551 opened on 2025/08/16

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (15 件のフォーク)auto 404
choredocumentationgood first issue

Repository metrics

Stars
 (132 個のスター)
PR merge metrics
 (平均マージ 25d 20h) (30d で 29 merged PRs)

説明

Task

In many of our test cases, we use the package glob-promise to easily read in a bunch of files, e.g.

it("should contain one javascript file in the output directory", async function () {
  expect(await glob.promise(path.join(this.context.publicDir, "*.js"))).to.have.lengthOf(1);
});

However, after we merged #1543 , we will have access to the fs.glob API from NodeJS, so would be nice to swap over to that. Then we could re-write the usage as follows:

it("should contain one javascript file in the output directory", async function () {
  const files = await Array.fromAsync(fs.promises.glob(
    "*.js",
    { cwd: new URL(".", import.meta.url)},
  ));

  expect(files.length).to.equal(1);
});

With that, we could also delete the glob and glob-promise dependency from the root monorepo's package.json.

We should also update the CONTRIBUTING.md sample, if applicable.


🗒️ Note to self: after doing this, we should also refactor all the tests to not need to import from node:url, but that can be its own issue

コントリビューターガイド