GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use fs.rm() instead of rimraf by kevinoid · Pull Request #296 · raszi/node-tmp

Conversation

@kevinoid

@kevinoid kevinoid commented Feb 28, 2024

Copy link
Copy Markdown
Contributor

A regression occurred in 0.2.2 which can be reproduced using:

const assert = require('assert');
const tmp = require('tmp');
tmp.dir({ unsafeCleanup: true }, (err, path, cleanup) => {
  assert.ifError(err);
  cleanup(assert.ifError);
});

This works with 0.2.1. With 0.2.2 it fails with:

/path/to/tmp/node-tmp/lib/tmp.js:358
        return removeFunction(fileOrDirName, next || function() {});
               ^

TypeError: removeFunction is not a function
    at _cleanupCallback (/path/to/tmp/node-tmp/lib/tmp.js:358:16)
    at /path/to/tmp/node-tmp/repro.js:5:3
    at _dirCreated (/path/to/tmp/node-tmp/lib/tmp.js:207:7)
    at FSReqCallback.oncomplete (node:fs:192:23)

This occurs because 00bb5b2 upgraded the rimraf dependency from ^3.0.0 to ^5.0.5 without handling the change to a Promise-based API in 4.0.0 (isaacs/rimraf@a71e7f9) or the removal of the default export in 5.0.0 (isaacs/rimraf@c7a3fd4).

This commit fixes the issue by dropping the rimraf dependency in favor of fs.rm({recursive: true}).

Thanks for considering,
Kevin

Fixes: #295

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MGschwindtFW reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
raszi
raszi previously approved these changes Feb 28, 2024
View reviewed changes

@raszi raszi left a comment

Copy link
Copy Markdown
Owner

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.

Looks good! Thank you very much!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@raszi

raszi commented Feb 28, 2024

Copy link
Copy Markdown
Owner

I believe the tests need to be updated as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kevinoid
kevinoid dismissed raszi’s stale review via 2e62837 February 28, 2024 23:20
@kevinoid
kevinoid force-pushed the drop-rimraf branch from 4e89567 to 2e62837 Compare February 28, 2024 23:20
@kevinoid

kevinoid commented Feb 28, 2024

Copy link
Copy Markdown
Contributor Author

My pleasure. Thanks for reviewing it @raszi.

I believe the tests need to be updated as well.

Whoops! Right you are. Sorry I missed that.

I've pushed a new version which updates the tests, package-lock.json, and the docs. Let me know if I've missed anything else.

P.S. How do you feel about support for Node.js 14.0 to 14.14 (when fs.rm() was added)? I have a fallback from fs.rm() to fs.rmdir() in lib/tmp.js to support <14.14, but didn't bother in the tests, since CI doesn't run it. Would it make sense to drop support for Node.js < 14.14, or to test it and add a CI job?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@raszi

raszi commented Feb 29, 2024

Copy link
Copy Markdown
Owner

I don't mind dropping that it isn't supported anymore:

https://nodejs.org/en/about/previous-releases

image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kevinoid
kevinoid force-pushed the drop-rimraf branch from 2e62837 to b8fa02c Compare February 29, 2024 01:30
@kevinoid

kevinoid commented Feb 29, 2024

Copy link
Copy Markdown
Contributor Author

Sounds good to me. I've dropped the fs.rmdir fallback to simplify the code a bit. Let me know if there are any other changes you'd like.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kevinoid
kevinoid force-pushed the drop-rimraf branch from b8fa02c to b7a13ee Compare February 29, 2024 01:40
@kevinoid

kevinoid commented Feb 29, 2024

Copy link
Copy Markdown
Contributor Author

Note: I just pushed an update to generate package-lock.json with npm from Node 14 to fix the CI error.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

raszi
raszi reviewed Feb 29, 2024
View reviewed changes
Comment thread package.json Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kevinoid
Use fs.rm() instead of rimraf
eafb034
A regression occurred in 0.2.2 which can be reproduced using:

```js
const assert = require('assert');
const tmp = require('tmp');
tmp.dir({ unsafeCleanup: true }, (err, path, cleanup) => {
  assert.ifError(err);
  cleanup(assert.ifError);
});
```
This works with 0.2.1.  With 0.2.2 it fails with:

    /path/to/tmp/node-tmp/lib/tmp.js:358
            return removeFunction(fileOrDirName, next || function() {});
                   ^

    TypeError: removeFunction is not a function
        at _cleanupCallback (/path/to/tmp/node-tmp/lib/tmp.js:358:16)
        at /path/to/tmp/node-tmp/repro.js:5:3
        at _dirCreated (/path/to/tmp/node-tmp/lib/tmp.js:207:7)
        at FSReqCallback.oncomplete (node:fs:192:23)

This occurs because 00bb5b2 upgraded
the rimraf dependency from ^3.0.0 to ^5.0.5 without handling the change
to a `Promise`-based API in 4.0.0
(isaacs/rimraf@a71e7f9)
or the removal of the default export in 5.0.0
(isaacs/rimraf@c7a3fd4).

This commit fixes the issue by dropping the `rimraf` dependency in favor
of `fs.rm({recursive: true})`.

It also updates the nodejs engine version to 14.14, when `fs.rm()` was
added.

Fixes: 00bb5b2 ("Update rimraf and drop old Node compatibility")
Fixes: raszi#295
Signed-off-by: Kevin Locke <[email protected]>
@kevinoid
kevinoid force-pushed the drop-rimraf branch from b7a13ee to eafb034 Compare February 29, 2024 01:46
raszi
raszi approved these changes Feb 29, 2024
View reviewed changes

@raszi raszi left a comment

Copy link
Copy Markdown
Owner

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.

Nice work! Thank you very much!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@raszi
raszi merged commit 6ed89d5 into raszi:master Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@raszi raszi raszi approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Upgrade of rimraf causes issue

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kevinoid @raszi
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.