[bugfix]: support Node versions 10-14 #35
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug where
depngn
would crash on Node versions<14
. (Resolves #34)Context
The
fs/promises
module was added to Node inv14
. Before that, starting inv10
, the Promises API was available underfs.promises
(so, you'd import it likerequire('fs').promises
). https://nodejs.org/api/fs.html#promises-apiOne solution to this would have been to conditionally import the correct module using dynamic imports:
But I didn't like the idea of littering the code with conditionals and (potentially) unnecessary async stuff. So, I opted for importing the old sync versions and wrapping them in
promisify
(which has the added benefit of being available starting in Nodev8
, so potentially more "unofficial" support?).Changes
utils
directoryaccess
andwriteFile
asyncExec
toutils
(and removedsrc/queries/exec.ts
)QA
Unfortunately, I'm now on an M1 Mac which hates letting
nvm
install Node versions<14
for some reason, so I can't manually test this on my machine (although, I did QA with newer Node versions and ran tests and everything works).To QA you would:
nvm use 12
(or any version>10 && <14
)depngn
Also
Hey everybody! Hope you're all doing well!