0.5.0 ā€¢ Published 3 years ago

@open-tech-world/node-rm v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@open-tech-world/node-rm

Linux Build macOS Build Windows Build CodeFactor npm

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.

Features

āœ”ļø Sync API

šŸš§ Async API

āœ”ļø Supports Multiple Patterns

Installation

Using npm

npm install @open-tech-world/node-rm

Using Yarn

yarn add @open-tech-world/node-rm

Usage

import { rmSync } from '@open-tech-world/node-rm';

rmSync(patterns: string | string[],
       options?: Partial<IOptions>): void;

Options

NameTypeDefaultDescription
cwdstringprocess.cwd()The current working directory in which to remove files & folders.
dotbooleanfalseIf true, it removes files & directories that begin with a "."(dot) character.
verbosebooleanfalseIf true, the current status will be output to the console.
colorsbooleanfalseIf true, it turns on color output.
drybooleanfalseIf true, it does not remove anything instead, it console logs what would be removed.

Examples

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

License

Copyright (c) 2021, Thanga Ganapathy (MIT License).