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

make-empty-dir

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

make-empty-dir

Ensures that a directory is empty

  • 1.1.0
  • next
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

make-empty-dir

Ensures that a directory is empty

npm version

Ensures that a directory is empty. Deletes directory contents if the directory is not empty. If the directory does not exist, it is created. The directory itself is not deleted.

It works faster than emptyDir() of fs-extra because the contents of the directory are not read before the creation of the directory.

Installation

<npm|yarn|pnpm> add make-empty-dir

Usage

'use strict'
const makeEmptyDir = require('make-empty-dir')

await makeEmptyDir('dir-name')

// or create the parent dir as well
await makeEmptyDir('dir/subdir', { recursive: true })

API

makeEmptyDir(dir: string, [opts]): Promise<'created' | 'emptied'>

Arguments:

  • dir - Path - the path of the directory.
  • opts.recursive - Boolean - Optional. If true, parent directories will be created.

Returns:

A string is returned.

  • 'created' - if there was no directory
  • 'emptied' - if there was a directory and the its contents were removed.

License

MIT © Zoltan Kochan

Keywords

FAQs

Package last updated on 11 Feb 2021

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