Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

premove

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

premove

A tiny (247B) utility to remove items recursively

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.3K
increased by14.59%
Maintainers
1
Weekly downloads
 
Created
Source

premove Build Status

A tiny (247B) utility to remove items recursively

This is a Promise-based utility that recursively removes files and directories.
It's effectively rm -rf for Node.js

Available in these formats:

  • ES Module: dist/premove.mjs
  • CommonJS: dist/premove.js

Important: Requires Node 8.x or later – uses async functions.

Install

$ npm install --save premove

Usage

import { resolve } from 'path';
import premove from 'premove';

// Async/await
try {
  await premove('./foobar');
} catch (err) {
  //
}

// Promise
premove('./foobar').then(val => {
  console.log(val); //=> undefined
}).catch(err => {
  //
});

// Using `cwd` option
const dir = resolve('./foo/bar');
await premove('hello.txt', { cwd: dir });

API

premove(str, opts={})

Returns: Promise<undefined> or false

Returns a Promise that resolves to undefined once complete.
Returns false immediately if the initial filepath (str) does not exist.

str

Type: String

The filepath to remove – may be a file or a directory.
An initial existence check is made for this filepath.

Important: This value is resolved to a full path.
Please be aware of how and from where the Node.js file system is resolving your path!

options.cwd

Type: String
Default: .

The directory to resolve your str from.
Defaults to the process.cwd() – aka, the directory that your command is run within.

  • mk-dirs – Create directories recursively
  • del - Delete files and folders using globs

License

MIT © Luke Edwards

Keywords

FAQs

Package last updated on 08 Jun 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc