🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

delete-files

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

delete-files

Asynchronously find and delete files in a folder

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Delete files

Asynchronously delete files in node.

Install

Yarn

yarn add delete-files

NPM

npm install delete-files --save 

Usage

deleteFiles(<folder>, [options]);

Example

Remove all files/folders in /dir beginning with tmp that are older than a day (age is specified in seconds).

const deleteFiles = require('delete-files');

const options = {
  age: 86400,
  glob: '^tmp',
};

deleteFiles('/dir', options);

If a glob is specified and a file does not match, no further options will be checked and the file will not be removed.

Implementation

The path for the directory to search must be specified with the full path. The age of a file is determined from the mtime (last modified). Files and folders are removed with the fs-extra remove function which is the equivalent of rm -rf.

FAQs

Package last updated on 25 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts