ProjectEvergreen/greenwood

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

开放

#1,551 创建于 2025年8月16日

 (0 条评论) (0 个反应) (0 位负责人)JavaScript (15 个派生)auto 404
choredocumentationgood first issue

仓库指标

星标
 (132 个星标)
PR 合并指标
 (平均合并 25天 20小时) (30 天内合并 29 个 PR)

描述

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

贡献者指南