Skip to content

Commit 4879b83

Browse files
authored
Merge pull request #332 from happo/recursive-fix
Fix recursing to find files in Node <18.17
2 parents 4b0c34e + f5cfbe8 commit 4879b83

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node: [18, 20, 22]
14+
node: ['18.16.0', 20, 22]
1515
name: Node ${{ matrix.node }}
1616
steps:
1717
- uses: actions/checkout@v4

src/deterministicArchive.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import crypto from 'crypto';
33
import fs from 'fs';
44
import path from 'path';
55

6+
import { glob } from 'glob';
67
import Archiver from 'archiver';
78

89
import validateArchive from './validateArchive';
@@ -22,20 +23,19 @@ async function resolveFilesRecursiveForDir(dirOrFile) {
2223
const isDir = (await fs.promises.lstat(resolvedDirOrFile)).isDirectory();
2324

2425
if (isDir) {
25-
const files = await fs.promises.readdir(resolvedDirOrFile, {
26-
withFileTypes: true,
27-
recursive: true,
26+
const files = await glob('**/*', {
27+
cwd: resolvedDirOrFile,
28+
nodir: true,
29+
absolute: true,
30+
dot: true,
2831
});
2932

30-
return files
31-
.filter((dirent) => dirent.isFile())
32-
.map((dirent) => {
33-
const fullPath = path.join(dirent.path, dirent.name);
34-
return {
35-
name: fullPath.slice(resolvedDirOrFile.length + 1),
36-
stream: fs.createReadStream(fullPath),
37-
};
38-
});
33+
return files.map((fullPath) => {
34+
return {
35+
name: path.relative(resolvedDirOrFile, fullPath),
36+
stream: fs.createReadStream(fullPath),
37+
};
38+
});
3939
}
4040

4141
return [

0 commit comments

Comments
 (0)