Remove files & directories using glob patterns.
Internally it uses open-tech-world/node-glob for matching files & directories. Refer it for supported glob patterns and more info.
✔️ Sync API
🚧 Async API
✔️ Supports Multiple Patterns
Using npm
npm install @open-tech-world/node-rm
Using Yarn
yarn add @open-tech-world/node-rm
import { rmSync } from '@open-tech-world/node-rm';
rmSync(patterns: string | string[],
options?: Partial<IOptions>): void;
Name | Type | Default | Description |
---|---|---|---|
cwd | string | process.cwd() | The current working directory in which to remove files & folders. |
dot | boolean | false | If true, it removes files & directories that begin with a "." (dot) character. |
verbose | boolean | false | If true, the current status will be output to the console. |
colors | boolean | false | If true, it turns on color output. |
dry | boolean | false | If true, it does not remove anything instead, it console logs what would be removed. |
my-app/
├─ node_modules/
├─ public/
│ ├─ favicon.ico
│ ├─ index.html
│ ├─ robots.txt
├─ src/
│ ├─ index.css
│ ├─ index.js
├─ .gitignore
├─ package.json
├─ README.md
import { rmSync } from '@open-tech-world/node-rm';
rmSync('public/*', { cwd: 'my-app', verbose: true });
// my-app/public/favicon.ico
// my-app/public/index.html
// my-app/public/robots.txt
import { rmSync } from '@open-tech-world/node-rm';
rmSync(['public/*', '!**/robots.txt'], { cwd: 'my-app', verbose: true });
// my-app/public/favicon.ico
// my-app/public/index.html
Copyright (c) 2021, Thanga Ganapathy (MIT License).