var del = require('delete');
// async
del(['foo/*.js'], function(err, deleted) {
if (err) throw err;
// deleted files
console.log(deleted);
});
// sync
del.sync(['foo/*.js']);
// promise
del.promise(['foo/*.js'])
.then(function(deleted) {
// deleted files
console.log(deleted)
});
All methods take an options
object as the second argument.
Type: boolean
Default: undefined
By default, error is thrown if you try to delete either the current working directory itself, or files outside of the current working directory (e.g. parent directories).
Examples
del.sync('../foo.md', {force: true});
del('.', {force: true}, function(err, files) {
// do stuff with err
console.log(files);
});
del.promise('./', {force: true})
.then(function(files) {
console.log(files);
})
(This option was inspired by settings in [grunt][].)