GithubHelp home page GithubHelp logo

del's Introduction

del

Delete files and directories 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.

Install

npm install del

Usage

import {deleteAsync} from 'del';

const deletedFilePaths = await deleteAsync(['temp/*.js', '!temp/unicorn.js']);
const deletedDirectoryPaths = await deleteAsync(['temp', 'public']);

console.log('Deleted files:\n', deletedFilePaths.join('\n'));
console.log('\n\n');
console.log('Deleted directories:\n', deletedDirectoryPaths.join('\n'));

Beware

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

So this won't work:

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

You have to explicitly ignore the parent directories too:

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

To delete all subdirectories inside public/, you can do:

deleteSync(['public/*/']);

Suggestions on how to improve this welcome!

API

Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use path.posix.join() instead of path.join().

deleteAsync(patterns, options?)

Returns Promise<string[]> with the deleted paths.

deleteSync(patterns, options?)

Returns string[] with the deleted paths.

patterns

Type: string | string[]

See the supported glob patterns.

options

Type: object

You can specify any of the globby options in addition to the below options. In contrast to the globby defaults, expandDirectories, onlyFiles, and followSymbolicLinks are false by default.

force

Type: boolean
Default: false

Allow deleting the current working directory and outside.

dryRun

Type: boolean
Default: false

See what would be deleted.

import {deleteAsync} from 'del';

const deletedPaths = await deleteAsync(['temp/*.js'], {dryRun: true});

console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n'));
dot

Type: boolean
Default: false

Allow patterns to match files/folders that start with a period (.).

This option is passed through to fast-glob.

Note that an explicit dot in a portion of the pattern will always match dot files.

Example

directory/
├── .editorconfig
└── package.json
import {deleteSync} from 'del';

deleteSync('*', {dot: false});
//=> ['package.json']
deleteSync('*', {dot: true});
//=> ['.editorconfig', 'package.json']
concurrency

Type: number
Default: Infinity
Minimum: 1

Concurrency limit.

onProgress

Type: (progress: ProgressData) => void

Called after each file or directory is deleted.

import {deleteAsync} from 'del';

await deleteAsync(patterns, {
	onProgress: progress => {
	// …
}});
ProgressData
{
	totalCount: number,
	deletedCount: number,
	percent: number,
	path?: string
}
  • percent is a value between 0 and 1
  • path is the absolute path of the deleted file or directory. It will not be present if nothing was deleted.

CLI

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

del for enterprise

Available as part of the Tidelift Subscription.

The maintainers of del and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Related

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

del's People

Contributors

bendingbender avatar chrisblossom avatar coreyfarrell avatar deadcoder0904 avatar diamondex avatar jonkoops avatar jopemachine avatar kevva avatar liuhanqu avatar luftywiranda13 avatar marchuffnagle avatar mrienstra avatar peterkc avatar realityking avatar richienb avatar samverschueren avatar schnittstabil avatar silvenon avatar simenb avatar sindresorhus avatar stbaer avatar vladshcherbin avatar wbinnssmith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

del's Issues

Not able to delete not empty directories windows 10

i have my folder structures like

- scripts
  - components
    - index.js
  - main.js
- styles
  - components
    - button.css
  - main.css

now i want to delete above folders so i did

del.sync(['./build/scripts/', './build/styles/'])

but it throws

Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\Maqbool\Desktop\Temperature\hrefli\.temp\scripts'
    at Error (native)
    at Object.fs.rmdirSync (fs.js:758:18)
    at rmkidsSync (C:\Users\Maqbool\Desktop\Temperature\hrefli\node_modules\del\node_modules\rimraf\rimraf.js:342:11)
    at rmdirSync (C:\Users\Maqbool\Desktop\Temperature\hrefli\node_modules\del\node_modules\rimraf\rimraf.js:332:7)
    at rimrafSync (C:\Users\Maqbool\Desktop\Temperature\hrefli\node_modules\del\node_modules\rimraf\rimraf.js:303:9)
    at C:\Users\Maqbool\Desktop\Temperature\hrefli\node_modules\del\node_modules\rimraf\rimraf.js:340:5
    at Array.forEach (native)
    at rmkidsSync (C:\Users\Maqbool\Desktop\Temperature\hrefli\node_modules\del\node_modules\rimraf\rimraf.js:339:26)
    at rmdirSync (C:\Users\Maqbool\Desktop\Temperature\hrefli\node_modules\del\node_modules\rimraf\rimraf.js:332:7)
    at Function.rimrafSync [as sync] (C:\Users\Maqbool\Desktop\Temperature\hrefli\node_modules\del\node_modules\rimraf\rimraf.js:303
:9)

i am on Windows 10 and using del 2.2.2

any help welcome thanks

del.sync() returns error but promisified del() does not

While trying to delete a directory with in-use files on Windows 10, del.sync() produced the error "Directory not empty" but running del().then(function, function) did not return an error in the second then() function.

Possible race condition with deleting files in directory

It's not a 100% repro, but occasionally, this fails to delete a directory from an error like this on my machine:

// cwd: /home/me/project
del("folder/**").then(() => { /* ... */ })
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, lstat '/home/me/project/folder/file.js'
    at Error (native)

I'm running Ubuntu, by the way.

Cannot delete a folder on a parent path like "../test/"

gulp.task("cleanBuildFolder", function () {
  return gulp.src("./test/")
    .pipe(vinyl(del))
    .pipe(gutil.noop());
});

worked

but accessing a folder in a parent folder one level up does not work

gulp.task("cleanBuildFolder", function () {
  return gulp.src("../test/") // note the "../"
    .pipe(vinyl(del))
    .pipe(gutil.noop());
});


What am I misunderstanding here?

Greets Charlie

delete files from network share

I was using grunt quite happely when I stumbled upon an issue in removing files from a network location with grunt-contrib-clean

So I just tried del in combination with gulp but ended having (at first glance) the same issue. I'm new to gulp so maybe i'm missing something. This is my extremely simple gulpfile.js

var gulp = require('gulp'),
    del = require('del');

gulp.task('clean', function(cb) {
    del(['//some/network/location/*'], { force: true }, cb)
});

gulp.task('default', function() {
    gulp.start('clean');
});

Running gulp gives me no errors but the files in //some/network/location are still there. Is this unsupported use, misuse or a bug?

I'm running gulp on a Windows 8 machine from within Git bash. Shared location is on my synology NAS.

Throw an error when callback is provided (or document change)

I realise this is totally my fault (because there's a major version bump) and you may not want the extra code in there, but I got caught by the switch from callbacks to promises when updating a bunch of dependencies.

Since there's no Changelog, a warning the API has changed would go a long way to making upgrades more painless; failing that, explicitly calling out the switch from callbacks to Promises near the top of the README would also help. As it is you need to read the docs and realise there's no longer a reference to callback support anywhere, and check the commit history to figure out what's going on.

=> this operator and how to use it?

How do you use this "=>". My gulp doesn't like it. I'm familiar with it in a C# context , where it means 'goes to'. Seems the same here.. but gulp doesn't understand it?

gulp.task('clean', function (cb) {
    del(['./dist/*']).then(paths => {      
    });
});

$ gulp
gulpfile.js:23
    del(['./dist/*']).then(paths => {
                                 ^^
SyntaxError: Unexpected token =>
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Liftoff.handleArguments (C:\Program Files\nodejs\node_modules\gulp\bin\gulp.js:116:3)

    at Liftoff.<anonymous> (C:\Program   Files\nodejs\node_modules\gulp\node_modules\liftoff\index.js:192:16) 
at module.exports (C:\Program Files\nodejs\node_modules\gulp\node_modules\liftoff\node_modules\flagged-respawn\index.js:17:3)
$ gulp -v
[11:02:35] CLI version 3.9.0
[11:02:35] Local version 3.9.0

Gulp task problem with del

Sincerely, I'm not so sure if this error is from this package or gulp. But you can help me.
When I call my gulp task clean

gulp.task('clean', cb => {
  del(['.tmp', 'dist/*', '!dist/.git'], {dot: true}).then(cb);
});

I get this:

[01:28:16] Requiring external module babel-core/register
[01:30:33] Using gulpfile d:\www\web-starter-kit\gulpfile.babel.js
[01:30:33] Starting 'clean'...
[01:30:34] 'clean' errored after 325 ms
[01:30:34] Error
    at formatError (C:\Users\ramasilveyra\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:169:10)
    at Gulp.<anonymous> (C:\Users\ramasilveyra\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:195:15)
    at emitOne (events.js:77:13)
    at Gulp.emit (events.js:169:7)
    at Gulp.Orchestrator._emitTaskDone (d:\www\web-starter-kit\node_modules\gulp\node_modules\orchestrator\index.js:264:8)
    at d:\www\web-starter-kit\node_modules\gulp\node_modules\orchestrator\index.js:275:23
    at finish (d:\www\web-starter-kit\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:21:8)
    at cb (d:\www\web-starter-kit\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:29:3)

Maybe a problem with the promise?

Using iojs 3.3.0 and latest del along with gulp - no joy

Using this simple pattern for a long time now in gulp:

var del = require('del');

gulp.task('clean', function(cb) {
    del(['output'], cb);
});

/**
 * Build Task
 *   - Build all the things...
 */

gulp.task('build', function (cb) {
  runSequence(
    'clean',                     // first clean
    ['lint', 'jscs'],            // then lint and jscs
    ['styles', 'scripts'],       // Then styles and scripts
    ['test'],                    // test it!
    cb);
});

Updated del yesterday when the new version came out and now my build stops at clean:

❯ gulp
[05:07:15] Using gulpfile ~/Code/bootstrap4-starter-kit/gulpfile.js
[05:07:15] Starting 'build'...
[05:07:15] Starting 'clean'...

No errors thrown...

Anyone have any ideas?

Case sensitivity on macOS

There are file systems which are not case sensitive.
This is problematic in a scenario, where I know that my application created file.txt in sub/dir, but I do not know if sub/dir is named sub/dir or Sub/Dir or sub/Dir or what.
To prevent sub/dir/file.txt from being removed I need not only:

[
 'sub/**',
 '!sub/dir/file.txt',
 '!sub/dir',
 '!sub',
]

but also all variants of sub, Sub, SUB, sUB.
It would be great to be able to pass 'case sensitivity' flag somewhere.

Delete files in pipechain

My understanding I can't use del inside a pipechain to remove files coming through the chain. Is my next option to go back to deprecated gulp-rimrafor is there a better alternative?

del.sync is still async

I'm using del with gulp and

gulp.task('del', function(done) {
return del.sync(path);
// also tried return done;
});

Gulp task doesn't return

Negating doesn't prevent deletion of the parent folder

For a project that I'm working on I used the following dir structure:

Parent Folder
All build files go here
- gulp (gulp file/content)
- src (working dir)

And I have the following build:cleanfolder task:

gulp.task('build:cleanfolder', function() {
    del([
        '!ParentFolder',
        '!../',
        '!../gulp',
        '!../src',
        '../**'
        ], {force: true});
});

So what I want is that whenever I run the build task, it empties the parentfolder ignoring the gulp, src maps and the parent folder. However, what happens is that it completely deletes the parent folder incl. its subfolders even though I negated both '../' and the Parent Folder.

Am I missing something obvious or is this a known issue (or am I just using it the wrong way)

Build is failing with error TypeError: Cannot read property 'length' of undefined

[15:14:09] TypeError in plugin 'run-sequence(clean:dist)'
Message:
Cannot read property 'length' of undefined
Stack:
TypeError: Cannot read property 'length' of undefined
at Function.glob.hasMagic /node_modules/del/node_modules/rimraf/node_modules/glob/glob.js:106:29)
at Function.rimrafSync as sync
at /home/loganathan/git/mysite/node_modules/del/index.js:68:11
at Array.map (native)
at Function.module.exports.sync (/home/loganathan/git/mysite/node_modules/del/index.js:60:37)
at Gulp. (/home/loganathan/git/mysite/gulpfile.js:131:14)
at module.exports /home/loganathan/git/mysite/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/home/loganathan/git/mysite/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/home/loganathan/git/mysite/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/home/loganathan/git/mysite/node_modules/gulp/node_modules/orchestrator/index.js:134:8)

Open to Promise API?

I'm wondering if you'd be open to me implementing a Promise API in addition to taking the callback. Could be useful for those using gulp (where this module seems to be frequently used as opposed to rimraf) who want a nice readable API. Would you take such a patch?

Exclude pattern hack

I've wrote a function to simplify writing exclude pattern, due to the fact that ** matches all children and the parent.

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

Here is my function:

function extendNegGlobs(arr) {
    var ext = [];
    var negs = {};
    arr.forEach((g, i) => {
        if ( g.slice(0,1) == '!' ) {
            negs[g] = i;
        }
    });
    Object.keys(negs).forEach((g) => {
        var d;
        if ( g.slice(-1) == '*' ) do {
            g = path.dirname(d = g);
            if ( g == '!' || g == '.' || g == d ) break;
            if ( !(g in negs) ) {
                negs[g] = ext.push(g);
            }
        }
        while ( true );
    });
    return arr.concat(ext);
}

I don't pretend this is a complete/nice solution, but it might be a starting point to finding one!

Comments ?

Requests confirmation when deleting folder contents

Windows 10, del v 3.0.0, del-cli v 1.1.0

When used in an npm script like this:

del "app/typings/models"

del requires "Are you sure" confirmation. This makes it entirely unsuitable for usage in CI.

Would it be possible to add option switch that would silently confirm on any prompts?

Sometimes error "EINVAL" when removing files in macOS temp directory

Sometimes when deleting a folder that has nested folders/files inside the macOS temp directory, error EINVAL is thrown. This is not happening when using .sync.

Minimal example repo: https://github.com/chrisblossom/del-issue-68

{ Error: EINVAL: invalid argument, rmdir '/var/folders/hm/n_tq5p6j7j313n28pjzvk63c0000gn/T/del-issue-68/a/b/c'
  errno: -22,
  code: 'EINVAL',
  syscall: 'rmdir',
  path: '/var/folders/hm/n_tq5p6j7j313n28pjzvk63c0000gn/T/del-issue-68/a/b/c' }
  System:
    OS: macOS High Sierra 10.13.3
    CPU: x64 Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
  Binaries:
    Node: 8.11.2 - ~/.nvm/versions/node/v8.11.2/bin/node
    Yarn: 1.7.0 - ~/.yarn/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.11.2/bin/npm

del is an alias for a native Windows command

I hesitate to even open this issue because I'm not even sure how you would go about addressing this, but it's a heads up, if anything. 'del' is an alias for the native Windows command for removing things. In essence, it kinda does what this module does, but natively. Unfortunately since the syntaxes differ, this node module throws errors when running on Windows....either when installed globally or, in my case, via an npm run script a la:

"scripts": {
    "clean": "del dist/*"
}

rimraf avoids these issues (because rimraf isn't an alias for anyting in Windows), but you've obviously made some improvements to rimraf functionality via the notes in your documentation.

Tests failing

I just run the tests and they are failing; wondering why do we have code not passing the tests on master.

Only 3 tests are passed:
captura de pantalla 2016-04-07 a las 10 13 40

Not sure if you were aware of this issue. Sorry if you are and prefer me not to fill an issue.

Cannot read property 'then' of undefined

Can't figure out what I'm missing.. Trying to adapt some version 1 code to version 2.

I have a file with the following content:

var del = require('del')

del(['.tmp', 'dist']).then(function(paths) {
  console.log(paths);
});

which I run on the command line like so:

$ node my_file.js

This results in the following error:

TypeError: Cannot read property 'then' of undefined
    at Object.<anonymous> (/path/to/file:3:14)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:118:18)
    at node.js:952:3

I'm running Node v4.1.2 on Mac OSX 10.11.

Is options.cwd official?

I have seen that there is an options.cwd option that allows you to set the current working directory when running del. This property is extremly useful, but unfortunately it is not documented.

So, my question is, am I safe to use it (in other words, it's just the documentation missing) or is it considered private and I should stick away from it?

Is ** supposed to match the base directory?

del('foo/bar/**') should not remove foo/bar, right?
del('foo/bar/*') and del('foo/bar/**/*') work as expected.

Maybe I just don't understand how the globstar option really works but my shell (zsh) doesn't touch the base directory.

Error: EPERM - rmdir

On rare occasions I get this:

[11:40:41] 'clean.build' errored after 412 ms
[11:40:41] Error: EPERM, rmdir 'W:\Workspace\my-project\build'
    at Error (native)

It happens on OSX too, but never got it on Linux

File has no permission entries, del returns exit code 0 / success

I'm using del to delete file like this (and in some cases directories *.css)

gulp.task("delete", function(cb) {
  del(["./deleteMe.txt"]).then(function (paths) { // returns a promise; https://github.com/sindresorhus/del
    console.log("Deleted files and folders: \n", paths.join('\n'));
    cb();
  }, function (reason) {
    cb("Failed to delete files " + reason);
  });
});

[08:55:51] Using gulpfile X:\Gulpfile.js
[08:55:51] Starting 'delete'...
[08:55:51] Finished 'delete' after 3.82 ms
Process terminated with code 0.
Deleted files and folders:

If the same task uses nodejs's fs it works, it reports error correctly:

fs.unlink("deleteMe.txt", function (reason) {
    console.log("Reason " + reason);
  });

Reason Error: EPERM: operation not permitted, unlink 'X:\deleteMe.txt'

deleteMe.txt permissions:

file_permissions

Gulp 4 task: "Did you forget to signal async completion?"

Setup

λ gulp -v
[10:52:08] CLI version 1.0.0
[10:52:08] Local version 4.0.0-alpha.2

del v2.1.0
Windows 7

Tasks

var del = require('del');
function clean() {
    return del(['docs', 'coverage', 'build', 'release']);
}

function build() {
    return gulp.series(
        clean
    );
}

gulp.task(build);

Error

λ gulp build
[10:52:22] Using gulpfile C:\project\gulpfile.js
[10:52:22] Starting 'build'...
[10:52:22] The following tasks did not complete: build
[10:52:22] Did you forget to signal async completion?

Am I missing something?

Returning a promise

When using multiple calls to del in a Gulp task, a callback or promise return is needed. It would be nice to use del in this case without a callback pyramid or hacky counter. Is there any reason del() shouldn't return a promise?

trying to understand the options (force)

I'm trying to understand where in the code to add the option to force outside the project directory.

force: true

gulp.task('clean', function(cb) {
    del(['**/*.html', 'css/*.css'], cb)
});

Curious about this vs. rimraf

Why is this better than just using rimraf? I'm just curious, because I see you write some wrappers around it, but you end up using rimraf to remove the globs provided.

Why hidden files are not deleted ?

Hello, I'm using del in as a gulp task :

gulp.task('clean', function() {
    var deferred = Q.defer();
    del(output + '**/*', function() {
        deferred.resolve();
    });
    return deferred.promise;
});

but when checking my output folder .htaccess fil is still there : is my syntax correct to also delete hidden files ? Thanks for your help !

No support for finally?

Got the following error:

TypeError: del(...).catch(...).finally is not a function

Given del has a promise interface, is there no support for a finally clause?

Printing the folder names

Hi,

Is there a way to log/print the folder names that are being deleted? I could use gulp-debug but, to use that I would need to pipe the list of files to debug, it will take care of printing it on screen.

Any idea How this can be achieved in del?

Too slow

can it be fast like gulp.src('./dist',{read:false}) ??

Consider bumping `globby`.

globby@7 comes with two new options: expandDirectories and gitignore. It would be nice to be able to use those from del. One potential problem I see with this proposal is that globby@7 now has nodir default to true, which may not be what is expected in the use cases for del.

Negating a pattern is not working

.
├── assets
│   ├── .gitkeep
│   ├── rev-manifest.json
│   ├── style-2ccbb519.css

I'm auto compiling my less and using gulp-rev for revisioning. I have a clean:css task defined like so:

gulp.task('clean:css', function (cb) {
    del(['public/assets/**', '!public/assets/.gitkeep'], cb);
});

When running the clean:css task everything in the public/assets directory is removed including .gitkeep, I expect .gitkeep to remain in place. I have replaced .gitkeep with example.txt to rule out problems with empty files and the problem persists (example.txt contained "example").

Have I missed something obvious, if not is there something I can do to debug this? I'm using ubuntu 14.04 (through Vagrant). Gulp is at version 3.8.7, npm is 1.3.10 and del is 0.1.1.

I followed this recipe.

Thank you!

dependency not capatible with 10+

keeping up with the jones here looks like upath version is not 10+ compatible.
upath (1.1.0) has been fixed for 10 but at least one of your dependencies hasn't upgraded.
anodynos/upath#21

ya del
yarn add v1.6.0
[1/4] Resolving packages...
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=4 <=9".
error Found incompatible module

How can I get the files deleted?

Is it possible through some option to return a set of filenames/paths which were actually deleted (i.e. which matched my pattern)?

Ignore pattern doesn't work outside working directory

When using this:

del(['public/assets/**', '!public/assets', '!public/assets/goat.png'], {
    dryRun: true
}).then(paths => console.log('Files and folders that would be deleted:\n' + paths.join('\n')));

I get this result:

Files and folders that would be deleted:
D:\Test\public\assets\cat.png
D:\Test\public\assets\dog.png
D:\Test\public\assets\horse.png

If I move the same directory structure to outside my working directory and change the del code to:

del(['/build/test/assets/**', '!/build/test/assets', '!/build/test/assets/goat.png'], {
    force: true,
    dryRun: true
}).then(paths => console.log('Files and folders that would be deleted:\n' + paths.join('\n')));

I get this result:

Files and folders that would be deleted:
D:\build\test\assets
D:\build\test\assets\cat.png
D:\build\test\assets\dog.png
D:\build\test\assets\goat.png
D:\build\test\assets\horse.png

delete .git folder

when running the following pattern it deletes .git folder

gulp.task('clean', del.sync(['dist/**', '!dist/', '!dist/.git/']) );

Please advice how to delete everything in the dist folder except .git folder.

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.