rmby ("remove by") is a zero-dependency Node.js library with a fluent interface for removing files asynchronously by certain aspects.
Node.js v10 or higher is required
$ npm i --save rmby$ yarn add rmby
RemoveFiles class is all you need. You can navigate yourself through the API by chaining methods, since the API provides a fluent interface. On the API section you can see more details about the usage.
In order to run your remove query, you have to call the
run() method at the end of your chain. This method will remove all files that match with your filter criteria and will return a
Promise<string> containing every file path that has been removed. If your filter cannot find matches, it will just return an empty array.
Remove Files By Time
Files can be removed by a time difference in milliseconds, seconds, minutes or hours. The time difference is always checked against the current time.
// Remove all files that are older than 12 hours;
Remove Files By Name
Files can be removed regarding its name without considering the file extension. You can remove files that match exactly, start with, end with, or include the name that you provide.
// Remove all files that start with "React";
Remove Files By Extension
Files can be removed regarding their file extension. You can remove files that match exactly with the extension you provide.
// Remove all .log files;
Remove Files By Combination
Files can be removed by combining the available filters. Therefore you can create more specific filters for your remove use case.
// Remove all log files that start with "app" and are older than 12 hours;
rmby is developed with TypeScript. The
master branch is used for development. Stable releases are always tagged with the latest version.
npm test. For code coverage, run
npm run test:cov. We have currently 100% code coverage and aim to stick with it.
The philosophy is to provide an easy to use library for file removal in Node.js, without dependencies and with a very declarative API. The fluent interface should guide the user through its use case.
rmby is currently maintained by Yadullah Duman