Skip to content

Commit dc2fd42

Browse files
committed
ignore unnecessary -rf or -fr
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
1 parent 89b38cf commit dc2fd42

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Improved hybrid module with no need to look at the `.default`
44
dangly bit. `.default` preserved as a reference to `rimraf`
55
for compatibility with anyone who came to rely on it in v4.0.
6+
- Accept and ignore `-rf` and `-fr` arguments to the bin.
67

78
# v4.0
89

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

1821
# v3.0
1922

src/bin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const main = async (...args: string[]) => {
5353
if (arg === '--') {
5454
dashdash = true
5555
continue
56+
} else if (arg === '-rf' || arg === '-fr') {
57+
// this never did anything, but people put it there I guess
58+
continue
5659
} else if (arg === '-h' || arg === '--help') {
5760
console.log(help)
5861
return 0

test/bin.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ t.test('basic arg parsing stuff', t => {
5151
])
5252
})
5353

54+
t.test('unnecessary -rf', async t => {
55+
t.equal(await bin('-rf', 'foo'), 0)
56+
t.equal(await bin('-fr', 'foo'), 0)
57+
t.equal(await bin('foo', '-rf'), 0)
58+
t.equal(await bin('foo', '-fr'), 0)
59+
t.same(LOGS, [])
60+
t.same(ERRS, [])
61+
t.same(CALLS, [
62+
['rimraf', ['foo'], {}],
63+
['rimraf', ['foo'], {}],
64+
['rimraf', ['foo'], {}],
65+
['rimraf', ['foo'], {}],
66+
])
67+
})
68+
5469
t.test('dashdash', async t => {
5570
t.equal(await bin('--', '-h'), 0)
5671
t.same(LOGS, [])
@@ -134,7 +149,14 @@ t.test('basic arg parsing stuff', t => {
134149
t.same(CALLS, [])
135150
})
136151

137-
const impls = ['rimraf', 'native', 'manual', 'posix', 'windows', 'move-remove']
152+
const impls = [
153+
'rimraf',
154+
'native',
155+
'manual',
156+
'posix',
157+
'windows',
158+
'move-remove',
159+
]
138160
for (const impl of impls) {
139161
t.test(`--impl=${impl}`, async t => {
140162
t.equal(await bin('foo', `--impl=${impl}`), 0)

0 commit comments

Comments
 (0)