Skip to content
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

Remove mkdirp and rimraf in favor of Node.js builtins #17696

Closed
wants to merge 3 commits into from
Closed

Remove mkdirp and rimraf in favor of Node.js builtins #17696

wants to merge 3 commits into from

Conversation

wojtekmaj
Copy link
Contributor

In Node.js v10.12.0, recursive option was added to fs.mkdirSync. This option allows you to create a directory and all its parent directories if they do not exist.

In Node.js v14.14.0, fs.rmSync was added. It's a built-in module that removes files and directories. The recursive option is used to remove directories and their contents.

Since pdf.js repository requires Node.js 18 and up, it's safe to assume mkdirp and rimraf can be safely replaced, thus reducing the number of dependencies in this project.

gulpfile.mjs Outdated
safeSpawnSync("git", ["clone", "--depth", "1", DIST_REPO_URL, DIST_DIR]);

console.log();
console.log("### Overwriting all files");
rimraf.sync(path.join(DIST_DIR, "*"));
fs.rmSync(DIST_DIR, { recursive: true, force: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the only line I'm not sure of

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run gulp dist-pre locally and compare the result with/without this patch you'll see that this change breaks things, since the output is no longer identical.

Hence this patch would reintroduce issue #15975, note in particular #15975 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, trying something else. I don't see the difference in outputs now, but I need a fresh brain to be sure.

gulpfile.mjs Outdated
safeSpawnSync("git", ["clone", "--depth", "1", DIST_REPO_URL, DIST_DIR]);

console.log();
console.log("### Overwriting all files");
rimraf.sync(path.join(DIST_DIR, "*"));
fs.rmSync(DIST_DIR, { recursive: true, force: true });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run gulp dist-pre locally and compare the result with/without this patch you'll see that this change breaks things, since the output is no longer identical.

Hence this patch would reintroduce issue #15975, note in particular #15975 (comment).

gulpfile.mjs Outdated Show resolved Hide resolved
@Snuffleupagus
Copy link
Collaborator

It's probably a good idea to split this into two separate PRs, one for mkdirp and one for rimraf, since replacing mkdirp seems less problematical/risky and thus might be able to land sooner.

@calixteman
Copy link
Contributor

Would it be possible to have few tests to check that we aren't breaking something again ?

@Snuffleupagus
Copy link
Collaborator

Closing this for now, since there's not been any updates for a couple of weeks and this cannot land in its current state (needs careful testing and no fixup commits for a start).

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.

3 participants