diff --git a/README.md b/README.md index 7ab1a5d6..dc14ec20 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ Synchronous form of `rimraf.moveRemove()` ### Command Line Interface ``` -rimraf version 4.3.0 +rimraf version 5.0.7 Usage: rimraf [ ...] Deletes all files and folders at "path", recursively. @@ -186,6 +186,7 @@ Deletes all files and folders at "path", recursively. Options: -- Treat all subsequent arguments as paths -h --help Display this usage info + --version Display version --preserve-root Do not remove '/' recursively (default) --no-preserve-root Do not treat '/' specially -G --no-glob Treat arguments as literal paths, not globs (default) diff --git a/src/bin.mts b/src/bin.mts index db47b660..098d1633 100755 --- a/src/bin.mts +++ b/src/bin.mts @@ -20,6 +20,7 @@ Deletes all files and folders at "path", recursively. Options: -- Treat all subsequent arguments as paths -h --help Display this usage info + --version Display version --preserve-root Do not remove '/' recursively (default) --no-preserve-root Do not treat '/' specially -G --no-glob Treat arguments as literal paths, not globs (default) @@ -158,6 +159,9 @@ const main = async (...args: string[]) => { } else if (arg === '-h' || arg === '--help') { console.log(help) return 0 + } else if (arg === '--version') { + console.log(version) + return 0 } else if (arg === '--interactive' || arg === '-i') { interactive = true continue @@ -258,6 +262,7 @@ const main = async (...args: string[]) => { return 0 } main.help = help +main.version = version export default main diff --git a/test/bin.ts b/test/bin.ts index fcfbbe3f..665f92c8 100644 --- a/test/bin.ts +++ b/test/bin.ts @@ -50,6 +50,19 @@ t.test('basic arg parsing stuff', async t => { CALLS.length = 0 }) + t.test('binary version', t => { + const cases = [['--version'], ['a', 'b', '--version', 'c']] + for (const c of cases) { + t.test(c.join(' '), async t => { + t.equal(await bin(...c), 0) + t.same(LOGS, [[bin.version]]) + t.same(ERRS, []) + t.same(CALLS, []) + }) + } + t.end() + }) + t.test('helpful output', t => { const cases = [['-h'], ['--help'], ['a', 'b', '--help', 'c']] for (const c of cases) {