Comments (10)
I am here too ..issues on shared drive requires the force option...here is my code
gulp.task('clean',function(){
return gulp.src(DEST)
.pipe(vinylPaths(del(DEST, { force: true })));
});
I was using vinylPaths as I wanted to do this on a stream of ONLY changed files
from del.
@jzp74 Read documentation, please. New api uses promises instead of callback.
from del.
@TrySound Thanks for your reply. You mean this documentation: https://github.com/gulpjs/gulp/blob/master/docs/API.md?
Not sure I understand how that would change my gulp clean task. Can you elaborate a bit more?
from del.
@jzp74 This documentation
https://github.com/sindresorhus/del
from del.
@jzp74 Instead of passing callback as the last argument you can just return result of del function. gulp tasks accept streams and promises.
from del.
@TrySound Thanks!
So I tried this with a normal directory
gulp.task('clean', function(cb) {
del(['dist/css/*.css'], { force: true });
cb();
});
Works perfectly. I then tried this (basically the same) with the shared location
gulp.task('clean', function(cb) {
del(['//some/network/location/dist/css/*.css'], { force: true });
cb();
});
Doesn't work and renders no errors or warning. This should work right?
Then tried this to see if something is perhaps wrong wiith my shared location.
gulp.task('clean', function (cb) {
exec('rm -fr //some/network/location/dist/css/*', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
})
Works perfectly. It looks like del doesn't work with shared locations. Am I still doing something wrong? Is there something else you would like me to test?
from del.
@jzp74 Do not use callback here. You call cb before del end.
gulp.task('clean', function() {
return del(['dist/css/*.css'], { force: true });
});
from del.
@jzp74 I don't know about shared location.
/cc @sindresorhus
from del.
Removed the callback for both the local delete and the shared location delete. Same results: local delete works, shared location delete doesn't
from del.
ATM, glob
does not support UNC globs, see isaacs/node-glob#74 and isaacs/node-glob#146. Thus, this also applies to del
.
However there's a workaround:
- use glob's
root
option: The place where patterns starting with/
will be mounted onto. - use a glob pattern starting with
/
. - use del's
force
option: Allow deleting the current working directory and outside.
Example:
del('/dist/css/*.css', {
root: '//ComputerName/SharedFolder',
force: true,
});
Notes:
-
globbing ComputerNames is not possible – Windows processes these in a different way
-
globbing SharedFolders is not possible – Windows processes these in a different way
-
Promises fail silently, i. e. to output error message one need to catch it:
del(…).then(console.log).catch(console.error)
-
Of course,
gulp
outputs errors, but only if one return the Promise:gulp.task('clean', function() { return del(…); });
This should answer all questions.
from del.
Related Issues (20)
- Cannot delete dirs containing files with invalid UTF8 sequences in their name HOT 7
- The example of doc don't work HOT 2
- Very confused at glob behavior in 5.x vs 4.x HOT 4
- gulp DeprecationWarning in node 14.5? HOT 1
- Typescript 2x Error HOT 1
- Delete all content except the folder HOT 3
- Plugin is not working with Electron App HOT 1
- Add `progress` event
- Filenames with parentheses not deleted
- why 'del' restores the files I have deleted using 'rimraf'
- 5. X and 6 X performs wildcard recursive directory deletion, which is invalid
- Weird problem in the npm page HOT 1
- Upgrade: v7 convert to ESM lets Disscuse the API HOT 6
- Error: Cannot delete files/directories outside the current working directory HOT 1
- Release Notes for version 7 are incorrect HOT 1
- Build fail when using Babel HOT 3
- Couldn't delete dot files in del7.0.0 HOT 1
- [v8] Make the `dot` option true by default?
- Cannot find module 'del' HOT 1
- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from del.