Skip to content

Conversation

@2colours
Copy link
Contributor

Resolves #157. Comments might be worth reading.

This is meant to be a simple and incremental refactor with relatively meaningful commits. All spectests pass after the modifications, and 3 direct dependencies have been eliminated in favor of Node's built-in fs/promises API.

As I mentioned before, fsPromises.cp is an experimental utility in Node 20 - however, I see no reason to come up with an intermediary solution when Node 20 itself is basically "oldstable" now and Node 22 promoted the same API to stable. I wouldn't expect any sort of trouble but in any case, this clearly seems to be a straight path.

There is no API breakage here because neither ncp nor the mv default imported functions ever returned called the callback with anything but an error.
Important lesson from the spectests: the copy we are aiming for is with "verbatim symlinks", ie. when encountering a symlink during copying, do **not** reify it, just create a symlink with the same target. Apparently this is how it worked. Without setting this right, the install command would fail some tests in funky ways.
Since we generally aim towards the async APIs that didn't even exist at the original writing of apm, I chose to replace this synchronous API with a Promise-based one and made the appropriate changes at the call site; relatively small modification in init.js
This certainly could be done nicer but this is the simplest incremental modification - mv is now gone for good, so long, Mr. Andrew Kelley, and thanks for all the fish!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace wrench with fs-extra/klaw

1 participant