Skip to content

Commit 5da38b7

Browse files
committed
refactor(create-react-router): use native Node.js instead of recursive-readdir
1 parent f8c9a71 commit 5da38b7

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

packages/create-react-router/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"gunzip-maybe": "^1.4.2",
4545
"log-update": "^5.0.1",
4646
"proxy-agent": "^6.3.0",
47-
"recursive-readdir": "^2.2.3",
4847
"semver": "^7.3.7",
4948
"sisteransi": "^1.0.5",
5049
"sort-package-json": "^1.55.0",

packages/create-react-router/utils.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import fs from "node:fs";
2+
import { readdir } from "node:fs/promises";
13
import path from "node:path";
24
import process from "node:process";
35
import os from "node:os";
4-
import fs from "node:fs";
56
import { type Key as ActionKey } from "node:readline";
67
import { erase, cursor } from "sisteransi";
78
import chalk from "chalk";
8-
import recursiveReaddir from "recursive-readdir";
99

1010
// https://no-color.org/
1111
const SUPPORTS_COLOR = chalk.supportsColor && !process.env.NO_COLOR;
@@ -292,14 +292,11 @@ export function stripDirectoryFromPath(dir: string, filePath: string) {
292292
export const IGNORED_TEMPLATE_DIRECTORIES = [".git", "node_modules"];
293293

294294
export async function getDirectoryFilesRecursive(dir: string) {
295-
let files = await recursiveReaddir(dir, [
296-
(file) => {
297-
let strippedFile = stripDirectoryFromPath(dir, file);
298-
let parts = strippedFile.split(path.sep);
299-
return (
300-
parts.length > 1 && IGNORED_TEMPLATE_DIRECTORIES.includes(parts[0])
301-
);
302-
},
303-
]);
304-
return files.map((f) => stripDirectoryFromPath(dir, f));
295+
return (await readdir(dir, { recursive: true })).filter((file) => {
296+
let parts = file.split(path.sep);
297+
298+
return (
299+
parts.length <= 1 || !IGNORED_TEMPLATE_DIRECTORIES.includes(parts[0])
300+
);
301+
});
305302
}

pnpm-lock.yaml

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)