GithubHelp home page GithubHelp logo

del's Introduction

del Build Status XO code style

Delete files and folders using globs

Similar to rimraf, but with a Promise API and support for multiple files and globbing. It also protects you against deleting the current working directory and above.


๐Ÿถ

Support this project and improve your JavaScript skills with this great ES6 course by Wes Bos.
Try his free JavaScript 30 course for a taste of what to expect. You might also like his React and Sublime course.


Install

$ npm install del

Usage

const del = require('del');

(async () => {
	const deletedPaths = await del(['tmp/*.js', '!tmp/unicorn.js']);

	console.log('Deleted files and folders:\n', deletedPaths.join('\n'));
})();

Beware

The glob pattern ** matches all children and the parent.

So this won't work:

del.sync(['public/assets/**', '!public/assets/goat.png']);

You have to explicitly ignore the parent directories too:

del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']);

Suggestions on how to improve this welcome!

API

del(patterns, [options])

Returns a promise for an array of deleted paths.

del.sync(patterns, [options])

Returns an array of deleted paths.

patterns

Type: string string[]

See supported minimatch patterns.

options

Type: Object

See the glob options.

force

Type: boolean
Default: false

Allow deleting the current working directory and outside.

dryRun

Type: boolean
Default: false

See what would be deleted.

const del = require('del');

(async () => {
	const deletedPaths = await del(['tmp/*.js'], {dryRun: true});

	console.log('Files and folders that would be deleted:\n', deletedPaths.join('\n'));
})();
concurrency

Type: number
Default: Infinity
Minimum: 1

Concurrency limit.

CLI

See del-cli for a CLI for this module and trash-cli for a safe version that is suitable for running by hand.

Related

  • make-dir - Make a directory and its parents if needed
  • globby - User-friendly glob matching

License

MIT ยฉ Sindre Sorhus

del's People

Contributors

diamondex avatar kevva avatar luftywiranda13 avatar peterkc avatar samverschueren avatar schnittstabil avatar sindresorhus avatar stbaer avatar vladshcherbin avatar wbinnssmith avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.