5.0.0 • Published 1 year ago

clear-folder v5.0.0

Weekly downloads
34
License
ISC
Repository
github
Last release
1 year ago

CircleCI

clear-folder

Clears the contents of a directory synchronously, for instance the build directory of your node package module.

Since version 4, clear-folder is an es-module. To use commonjs modules, use clear-folder version 3.x.x.

Safe deleting

Clear-folder is a cli app, intended to use safely in the scripts section of a package.json. It just uses the synchronous methods of the node.js fs module. The directory to clear must be inside the current directory. For brevity you may call this app with 'cf' instead of 'clear-folder'.

Usage

Add a number of names of folders to empty:

"scripts": {
    "...": "...",
    "prebuild": "cf folder1 folder2",
    "...": "..."
}

On the command line:

npx cf folder

In a script:

import cf from 'clear-folder'
...
const returnValue = cf(['folder1', 'folder2'])

In a script, return codes are available.

When folders were emptied, the folder count is returned. When no folders are specified, clear-folder prints an helpful message and returns -1. When one of folders points at or outside the current working directory, clear-folder aborts and returns -1.

5.0.0

1 year ago

3.2.1

2 years ago

3.2.0

2 years ago

4.1.0

2 years ago

3.1.0

2 years ago

4.0.0

2 years ago

3.0.0

3 years ago

2.0.0

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago