clean-up is a tool to help delete unwanted files from a directory. It can be used as a CLI tool, as a NodeJS module or running it as a command in your CI pipelines.
You can install clean-up globally by running the command:
- Using npm -
npm install clean-up -g. - Using Yarn -
yarn global add clean-up.
You can also install it as a dependency on your project by running the commands:
- Using npm -
npm install clean-up --save. - Using Yarn -
yarn add clean-up.
clean-up can be used in 2 way:
- As a CLI tool to be used either in your local development environment or CI pipelines.
- As a NodeJS module to be used via
require('clean-up').
As a CLI tool, it comes with 2 flavors:
- Interactive mode - this allows you to enter/select options and flags interactively.
- CLI arguments mode - you specify all the options and flags when calling the tool via the terminal.
To use the tool in your NodeJS module just require it using :
require('clean-up').
To use it as a CLI tool in interactive mode just run the command:node clean-up.
To use it as a CLI too in CLI arguments mode, just run the command:node clean-up [options] [flags].
-
delete-Objectwith the delete options. It includes:filename- glob pattern.age- the age of the file as amomentobject. You can use operators such as less than<, equal to=, greater than>, less than or equal to<=and greater than or equal to>=.size- size in bytes. You can use operators such as less than<, equal to=, greater than>, less than or equal to<=and greater than or equal to>=.
-
ignore-Objectthat has the options to ignore. It includes:filename- glob pattern.age- the age of the file as amomentobject. You can use operators such as less than<, equal to=, greater than>, less than or equal to<=and greater than or equal to>=.size- size in bytes. You can use operators such as less than<, equal to=, greater than>, less than or equal to<=and greater than or equal to>=.
-
limit-Objectto indicate the operations limits such as:max-file-number- maximum number of files to delete.sort-by- how to sort the files being cleaned up. The options arename,ageandsize.sort-direction- whether to sort byASCorDESC.
-
cron- cron pattern to indicate how often to run the delete operation.
As a CLI tool, you can pass the following flags to dictate how the tool will do the delete operation:
--recursiveor-r- a boolean value to delete files in subfolders as well.--levels = <number>or-l=<number>- used together with the--recursiveflag to indicate the level of subdirectories to delete files in.--verboseor-v- a boolean value to indicate whether to show logs on the terminal.--soft-deleteor-sd- a boolean value to indicate whether to just put the deleted files in the trash or to delete them permanently.--dry-runor-dr- a boolean value to indicate whether to show the details of the files to be deleted (number of files, total size).--helpor-h- a boolean value to show the tool's manual.--versionor-v- a boolean value to show the tool's version.
