diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55d42c5..8d6fe52 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/src/deterministicArchive.js b/src/deterministicArchive.js index 4041f5d..b98ce3f 100644 --- a/src/deterministicArchive.js +++ b/src/deterministicArchive.js @@ -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'; @@ -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 [