ProjectEvergreen/greenwood

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

Aperta

#1551 aperta il 16 ago 2025

 (0 commenti) (0 reazioni) (0 assegnatari)JavaScript (15 fork)auto 404
choredocumentationgood first issue

Metriche repository

Star
 (132 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor