Skip to content

Commit

Permalink
Merge pull request #332 from happo/recursive-fix
Browse files Browse the repository at this point in the history
Fix recursing to find files in Node <18.17
  • Loading branch information
lencioni authored Feb 18, 2025
2 parents 4b0c34e + f5cfbe8 commit 4879b83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20, 22]
node: ['18.16.0', 20, 22]
name: Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v4
Expand Down
24 changes: 12 additions & 12 deletions src/deterministicArchive.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import crypto from 'crypto';
import fs from 'fs';
import path from 'path';

import { glob } from 'glob';
import Archiver from 'archiver';

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

if (isDir) {
const files = await fs.promises.readdir(resolvedDirOrFile, {
withFileTypes: true,
recursive: true,
const files = await glob('**/*', {
cwd: resolvedDirOrFile,
nodir: true,
absolute: true,
dot: true,
});

return files
.filter((dirent) => dirent.isFile())
.map((dirent) => {
const fullPath = path.join(dirent.path, dirent.name);
return {
name: fullPath.slice(resolvedDirOrFile.length + 1),
stream: fs.createReadStream(fullPath),
};
});
return files.map((fullPath) => {
return {
name: path.relative(resolvedDirOrFile, fullPath),
stream: fs.createReadStream(fullPath),
};
});
}

return [
Expand Down

0 comments on commit 4879b83

Please sign in to comment.