From e09e1b20523d0d1386c26ea3ec36fe3442da65c2 Mon Sep 17 00:00:00 2001 From: "Michael \"Z\" Goddard" Date: Wed, 4 Oct 2023 11:24:52 -0400 Subject: [PATCH 1/2] update-bcd: Replace klaw with fdir --- scripts/update-bcd.ts | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/update-bcd.ts b/scripts/update-bcd.ts index 4ccf8e80c..121916276 100644 --- a/scripts/update-bcd.ts +++ b/scripts/update-bcd.ts @@ -29,7 +29,7 @@ import { } from "compare-versions"; import esMain from "es-main"; import fs from "fs-extra"; -import klaw from "klaw"; +import {fdir} from "fdir"; import {Minimatch} from "minimatch"; import yargs from "yargs"; import {hideBin} from "yargs/helpers"; @@ -579,25 +579,21 @@ export const update = ( export const loadJsonFiles = async ( paths: string[], ): Promise<{[filename: string]: any}> => { - // Ignores .DS_Store, .git, etc. - const dotFilter = (item) => { - const basename = path.basename(item); - return basename === "." || basename[0] !== "."; - }; + const jsonCrawler = new fdir() + .withFullPaths() + .filter((item) => { + // Ignores .DS_Store, .git, etc. + const basename = path.basename(item); + return basename === "." || basename[0] !== "."; + }) + .filter((item) => item.endsWith(".json")); const jsonFiles: string[] = []; for (const p of paths) { - await new Promise((resolve, reject) => { - klaw(p, {filter: dotFilter}) - .on("data", (item) => { - if (item.path.endsWith(".json")) { - jsonFiles.push(item.path); - } - }) - .on("error", reject) - .on("end", resolve); - }); + for (const item of await jsonCrawler.crawl(p).withPromise()) { + jsonFiles.push(item); + } } const entries = await Promise.all( From 10aeb7f8822da51d23e09af4cc0235e042aef31b Mon Sep 17 00:00:00 2001 From: "Michael \"Z\" Goddard" Date: Wed, 4 Oct 2023 11:44:49 -0400 Subject: [PATCH 2/2] remove klaw dependency --- package-lock.json | 10 ---------- package.json | 1 - 2 files changed, 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4a90eaad0..89c7857a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,7 +75,6 @@ "eslint-plugin-unicorn": "^48.0.1", "fdir": "6.1.0", "json3": "3.3.3", - "klaw": "4.1.0", "listr2": "6.6.1", "minimatch": "9.0.3", "mocha": "10.2.0", @@ -8100,15 +8099,6 @@ "node": ">=0.10.0" } }, - "node_modules/klaw": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-4.1.0.tgz", - "integrity": "sha512-1zGZ9MF9H22UnkpVeuaGKOjfA2t6WrfdrJmGjy16ykcjnKQDmHVX+KI477rpbGevz/5FD4MC3xf1oxylBgcaQw==", - "dev": true, - "engines": { - "node": ">=14.14.0" - } - }, "node_modules/kuler": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", diff --git a/package.json b/package.json index 123f3f1b5..b0b6d8cba 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,6 @@ "eslint-plugin-unicorn": "^48.0.1", "fdir": "6.1.0", "json3": "3.3.3", - "klaw": "4.1.0", "listr2": "6.6.1", "minimatch": "9.0.3", "mocha": "10.2.0",