0.0.5 • Published 6 months ago
@chriscdn/find-nuke v0.0.5
@chriscdn/find-nuke
A tool to recursively find and delete files with specified extensions that are older than a given duration.
Installation
To install using npm:
npm install @chriscdn/find-nukeTo install using yarn:
yarn add @chriscdn/find-nukeUsage
import { findNuke } from "@chriscdn/find-nuke";
const results = await findNuke("./file/path", {
  olderThan: Duration.with({ days: 4 }),
  extensions: [".pdf"],
  dryRun: true,
  deleteEmptyDirectories: true,
  verbose: false,
});Important: All options are optional. If no options are provided, the function will delete all files, so use with caution.
Options:
olderThan(optional): Deletes files older than the specified duration. This feature relies on the @chriscdn/duration package.extensions(optional): Specifies an array of file extensions (including the leading dot) to delete.dryRun(optional): If set totrue, lists files that would be deleted without actually deleting them. Defaults tofalse.deleteEmptyDirectories(optional): If set totrue, removes empty directories after file deletions. Does not include the root directory. Defaults tofalse.verbose(optional): When set totrue, additional details about the action are logged to the console. The default value isfalse.
Running Tests
The tests simulate various use cases with different parameters.
yarn test