Skip to content

Commit

Permalink
chore: replace path-scurry w/ fdir
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Aug 13, 2024
1 parent 2e38510 commit 52fb6c6
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 31 deletions.
104 changes: 90 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
"eslint": "^8.57.0",
"eslint-config-sukka": "^4.1.10",
"eslint-formatter-sukka": "^4.1.10",
"fdir": "^6.2.0",
"mocha": "^10.4.0",
"mocha-chai-jest-snapshot": "^1.1.4",
"path-scurry": "^1.10.2",
"picocolors": "^1.0.0",
"rimraf": "^5.0.5",
"rollup": "^4.14.0",
Expand Down
34 changes: 18 additions & 16 deletions test/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import fsp from 'fs/promises';

import { PathScurry } from 'path-scurry';
import { fdir as Fdir } from 'fdir';

import { rollup as rollup2 } from 'rollup2';
import { rollup as rollup3 } from 'rollup3';
Expand Down Expand Up @@ -108,21 +108,23 @@ const tests = (rollupImpl: typeof rollup2 | typeof rollup3 | typeof rollup4, iso
const dirs = new Set<string>();
const files: Array<[from: string, to: string]> = [];

const pw = new PathScurry(fixtureDir);
for await (const entry of pw) {
if (entry.isFile()) {
const from = entry.fullpath();
const to = path.join(testDir, entry.relative());
const toDir = path.dirname(to);

dirs.add(toDir);
files.push([from, to]);

if (entry.name === 'package.json') {
const pkg = JSON.parse(await fsp.readFile(from, 'utf8'));
if (pkg.devDependencies || pkg.dependencies) {
requireInstall = true;
}
const entries = await new Fdir()
.withRelativePaths()
.crawl(fixtureDir)
.withPromise();

for (const entry of entries) {
const from = fixtureDir + path.sep + entry;
const to = path.join(testDir, entry);
const toDir = path.dirname(to);

dirs.add(toDir);
files.push([from, to]);

if (entry === 'package.json') {
const pkg = JSON.parse(await fsp.readFile(from, 'utf8'));
if (pkg.devDependencies || pkg.dependencies) {
requireInstall = true;
}
}
}
Expand Down

0 comments on commit 52fb6c6

Please sign in to comment.