Skip to content

Commit a09357b

Browse files
committed
feat: Reimplement rm command
1 parent b2dcc41 commit a09357b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/commands/rm.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import fs from 'node:fs';
2+
3+
function rm(path: string, options: {
4+
recursive: boolean;
5+
force: boolean;
6+
}) {
7+
fs.rmSync(path, {
8+
recursive: options.recursive,
9+
force: options.force,
10+
});
11+
}
12+
13+
export default rm;

src/index.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
import { Command } from 'commander';
33
import { version } from '../package.json';
44
import cp from './commands/cp';
5+
import rm from './commands/rm';
56
import server from './commands/server';
67

78
const program = new Command()
8-
.name('fsx')
9+
.name('du')
910
.description('A collection of cross-platform compatible functions and shell commands that aid in npm package development.')
1011
.version(version);
1112

@@ -18,6 +19,13 @@ program.command('cp')
1819
.option('-i, --ignore <string>', 'Ignore file(s) or directory')
1920
.action(cp);
2021

22+
program.command('rm')
23+
.description('Remove files and directories.')
24+
.argument('<string>', 'File or directory to remove')
25+
.option('-r, --recursive', 'Remove directories recursively', false)
26+
.option('-f, --force', 'Ignore nonexistent files and arguments', false)
27+
.action(rm);
28+
2129
program.command('server')
2230
.description('Host a static local server using the specified directory as root.')
2331
.argument('<string>', 'Root directory')

0 commit comments

Comments
 (0)