Skip to content

Commit

Permalink
ignore unnecessary -rf or -fr
Browse files Browse the repository at this point in the history
rimraf is always 'rm -rf', that's how it got its name

Updated changelog with this overlooked breaking change in v4.0, and
added the newly ignored -rf/-fr to the changelog for v4.1.

Fix: #253
  • Loading branch information
isaacs committed Jan 24, 2023
1 parent 89b38cf commit dc2fd42
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Improved hybrid module with no need to look at the `.default`
dangly bit. `.default` preserved as a reference to `rimraf`
for compatibility with anyone who came to rely on it in v4.0.
- Accept and ignore `-rf` and `-fr` arguments to the bin.

# v4.0

Expand All @@ -14,6 +15,8 @@
- Drop support for Node.js below version 14
- rewrite in TypeScript
- ship CJS/ESM hybrid module
- Error on ignore unknown arguments to the bin. (Previously they
were silently ignored.)

# v3.0

Expand Down
3 changes: 3 additions & 0 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const main = async (...args: string[]) => {
if (arg === '--') {
dashdash = true
continue
} else if (arg === '-rf' || arg === '-fr') {
// this never did anything, but people put it there I guess
continue
} else if (arg === '-h' || arg === '--help') {
console.log(help)
return 0
Expand Down
24 changes: 23 additions & 1 deletion test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ t.test('basic arg parsing stuff', t => {
])
})

t.test('unnecessary -rf', async t => {
t.equal(await bin('-rf', 'foo'), 0)
t.equal(await bin('-fr', 'foo'), 0)
t.equal(await bin('foo', '-rf'), 0)
t.equal(await bin('foo', '-fr'), 0)
t.same(LOGS, [])
t.same(ERRS, [])
t.same(CALLS, [
['rimraf', ['foo'], {}],
['rimraf', ['foo'], {}],
['rimraf', ['foo'], {}],
['rimraf', ['foo'], {}],
])
})

t.test('dashdash', async t => {
t.equal(await bin('--', '-h'), 0)
t.same(LOGS, [])
Expand Down Expand Up @@ -134,7 +149,14 @@ t.test('basic arg parsing stuff', t => {
t.same(CALLS, [])
})

const impls = ['rimraf', 'native', 'manual', 'posix', 'windows', 'move-remove']
const impls = [
'rimraf',
'native',
'manual',
'posix',
'windows',
'move-remove',
]
for (const impl of impls) {
t.test(`--impl=${impl}`, async t => {
t.equal(await bin('foo', `--impl=${impl}`), 0)
Expand Down

0 comments on commit dc2fd42

Please sign in to comment.