From 4a4295a6a196de51f122d7d9206f6d24d847892e Mon Sep 17 00:00:00 2001 From: David Sanders Date: Mon, 21 Oct 2024 16:07:15 -0700 Subject: [PATCH] refactor: use recursive option with fs.readdir --- package.json | 2 -- src/main/electron-types.ts | 8 +++++--- yarn.lock | 14 -------------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 85fb29214d..03c006d2b4 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,6 @@ "@types/react": "^16.14.0", "@types/react-dom": "^16.9.11", "@types/react-window": "^1.8.5", - "@types/recursive-readdir": "^2.2.0", "@types/semver": "^7.3.4", "@types/tmp": "0.2.0", "@typescript-eslint/eslint-plugin": "^6.0.0", @@ -136,7 +135,6 @@ "postcss": "^8.4.25", "postcss-less": "^6.0.0", "prettier": "^3.0.0", - "recursive-readdir": "^2.2.2", "resolve-url-loader": "^5.0.0", "standard": "^17.1.0", "stylelint": "^15.10.1", diff --git a/src/main/electron-types.ts b/src/main/electron-types.ts index 51b6553a9f..9bff99a415 100644 --- a/src/main/electron-types.ts +++ b/src/main/electron-types.ts @@ -1,3 +1,4 @@ +import { readdir } from 'fs/promises'; import * as path from 'node:path'; import { ElectronVersions } from '@electron/fiddle-core'; @@ -5,7 +6,6 @@ import { BrowserWindow, IpcMainEvent, app } from 'electron'; import * as fs from 'fs-extra'; import watch from 'node-watch'; import packageJson from 'package-json'; -import readdir from 'recursive-readdir'; import semver from 'semver'; import { ipcMainManager } from './ipc'; @@ -123,11 +123,13 @@ export class ElectronTypes { const types: NodeTypes = {}; try { - const files = (await readdir(dir)).filter((f) => f.endsWith('.d.ts')); + const files = (await readdir(dir, { recursive: true })).filter((f) => + f.endsWith('.d.ts'), + ); for (const file of files) { types[path.relative(dir, file) as keyof NodeTypes] = await fs.readFile( - file, + path.join(dir, file), 'utf8', ); } diff --git a/yarn.lock b/yarn.lock index ea6a09206b..959f15d0dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2577,13 +2577,6 @@ "@types/scheduler" "*" csstype "^3.0.2" -"@types/recursive-readdir@^2.2.0": - version "2.2.1" - resolved "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.1.tgz" - integrity sha512-Xd+Ptc4/F2ueInqy5yK2FI5FxtwwbX2+VZpcg+9oYsFJVen8qQKGapCr+Bi5wQtHU1cTXT8s+07lo/nKPgu8Gg== - dependencies: - "@types/node" "*" - "@types/responselike@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" @@ -10219,13 +10212,6 @@ rechoir@^0.8.0: dependencies: resolve "^1.20.0" -recursive-readdir@^2.2.2: - version "2.2.3" - resolved "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.3.tgz" - integrity sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA== - dependencies: - minimatch "^3.0.5" - redent@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz"