-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix recursing to find files in Node <18.17 #332
Conversation
The `path` and `parentPath` properties of a Dirent object isn't available until 18.17 and 18.20 respectively. To make our package compatible again with older Node versions, I'm switching out `fs.readdir` for `glob`. WIP because I can't figure out how to use the regular async version of `glob`.
So that we will replicate the bug with using fs.readdir together with dirent.paht.
@@ -11,7 +11,7 @@ jobs: | |||
runs-on: ubuntu-latest | |||
strategy: | |||
matrix: | |||
node: [18, 20, 22] | |||
node: ['18.16.0', 20, 22] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's update the engines field in package.json to match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh or maybe with this change we actually end up supporting back more so we can leave engines where it is at now.
src/deterministicArchive.js
Outdated
withFileTypes: true, | ||
recursive: true, | ||
const files = Array.from( | ||
await glob.sync('**/*', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await glob.sync
is a bit strange for a couple of reasons:
globSync
is a named export of the glob package, that I think we'd want instead of this if we want synchronous modeawait
a sync function is unnecessary- Since we are in an async function can we use the async glob?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I kept glob.sync
because of issues locally. Turns out I hadn't yarn install
ed in a while.
`await glob.sync` is a bit strange for a couple of reasons: 1. `globSync` is a named export of the glob package, that I think we'd want instead of this if we want synchronous mode 2. `await` a sync function is unnecessary 3. Since we are in an async function can we use the async glob? This seems to work fine for me, so I think we should make this change.
The
path
andparentPath
properties of a Dirent object isn't available until 18.17 and 18.20 respectively. To make our package compatible again with older Node versions, I'm switching outfs.readdir
forglob
.