Skip to content

Commit

Permalink
refactor: use recursive option with fs.readdir
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 committed Oct 21, 2024
1 parent 6191fb4 commit 4a4295a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions src/main/electron-types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { readdir } from 'fs/promises';
import * as path from 'node:path';

import { ElectronVersions } from '@electron/fiddle-core';
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';
Expand Down Expand Up @@ -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',
);
}
Expand Down
14 changes: 0 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 4a4295a

Please sign in to comment.