|
| 1 | +import fs from "node:fs"; |
| 2 | +import { readdir } from "node:fs/promises"; |
1 | 3 | import path from "node:path";
|
2 | 4 | import process from "node:process";
|
3 | 5 | import os from "node:os";
|
4 |
| -import fs from "node:fs"; |
5 | 6 | import { type Key as ActionKey } from "node:readline";
|
6 | 7 | import { erase, cursor } from "sisteransi";
|
7 | 8 | import chalk from "chalk";
|
8 |
| -import recursiveReaddir from "recursive-readdir"; |
9 | 9 |
|
10 | 10 | // https://no-color.org/
|
11 | 11 | const SUPPORTS_COLOR = chalk.supportsColor && !process.env.NO_COLOR;
|
@@ -292,14 +292,11 @@ export function stripDirectoryFromPath(dir: string, filePath: string) {
|
292 | 292 | export const IGNORED_TEMPLATE_DIRECTORIES = [".git", "node_modules"];
|
293 | 293 |
|
294 | 294 | 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 | + }); |
305 | 302 | }
|
0 commit comments