Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete files from network share #35

Closed
jzp74 opened this issue Sep 15, 2015 · 10 comments
Closed

delete files from network share #35

jzp74 opened this issue Sep 15, 2015 · 10 comments
Assignees

Comments

@jzp74
Copy link

jzp74 commented Sep 15, 2015

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.

@TrySound
Copy link

@jzp74 Read documentation, please. New api uses promises instead of callback.

@jzp74
Copy link
Author

jzp74 commented Sep 15, 2015

@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?

@TrySound
Copy link

@jzp74 This documentation
https://github.com/sindresorhus/del

@TrySound
Copy link

@jzp74 Instead of passing callback as the last argument you can just return result of del function. gulp tasks accept streams and promises.

@jzp74
Copy link
Author

jzp74 commented Sep 16, 2015

@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?

@TrySound
Copy link

@jzp74 Do not use callback here. You call cb before del end.

gulp.task('clean', function() {
    return del(['dist/css/*.css'], { force: true });
});

@TrySound
Copy link

@jzp74 I don't know about shared location.
/cc @sindresorhus

@jzp74
Copy link
Author

jzp74 commented Sep 16, 2015

Removed the callback for both the local delete and the shared location delete. Same results: local delete works, shared location delete doesn't

@landed1
Copy link

landed1 commented Oct 15, 2015

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

@schnittstabil
Copy link
Collaborator

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:

  1. use glob's root option: The place where patterns starting with / will be mounted onto.
  2. use a glob pattern starting with /.
  3. use del's force option: Allow deleting the current working directory and outside.

Example:

del('/dist/css/*.css', {
  root: '//ComputerName/SharedFolder',
  force: true,
});

Notes:

  1. globbing ComputerNames is not possible – Windows processes these in a different way

  2. globbing SharedFolders is not possible – Windows processes these in a different way

  3. Promises fail silently, i. e. to output error message one need to catch it:

    del().then(console.log).catch(console.error)
  4. Of course, gulp outputs errors, but only if one return the Promise:

    gulp.task('clean', function() {
      return del();
    });

This should answer all questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants