-
Notifications
You must be signed in to change notification settings - Fork 37
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(rm): ignore NotFound
errors when --force
flag is set
#93
Conversation
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.
Thanks @pkedy! Would you be able to add a test to mod.test.ts for this under "test remove" to ensure we don't get a regression in the future?
src/commands/rm.ts
Outdated
); | ||
} | ||
|
||
return Deno.remove(path, { recursive: flags.recursive }); |
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.
I believe it should just be a try/catch around this Deno.remove
only so it doesn't exit if one of the paths fails?
Maybe just:
return Deno.remove(path, { recursive: flags.recursive }).catch(err => {
if (flags.force && err instanceof Deno.errors.NotFound) {
return Promise.resolve();
} else {
return Promise.reject(err);
}
});
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.
I tried the try/catch around the Deno.remove
and the exception still bubbled up. Your snippet with catch
looks promising and worth a try though. I'll also see about adding a test.
Thanks for this project, BTW. I needed something like shx
for Deno in our code generation project called Apex and this fits the bill!
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.
That project looks really useful.
Adding test for rm -Rf. (not sure what the windows error message will be expecting failed test in CI).
@dsherret I added the test. Pls approve the workflow to run. I'm expecting the test to fail on Windows because I don't know how the OS error from |
I have a Windows machine. I'll fix it locally on Windows then push to the PR. |
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.
LGTM. Thanks @pkedy! I will do a release later today.
NotFound
errors when --force
flag is set
This PR adds a try/catch inside
executeRemove
and ignores NotFound errors whenforce
is set.This is inline with the behavior of
rm -Rf
on Unix.