question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

delete files from network share

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
landed1commented, Feb 16, 2016

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

0reactions
schnittstabilcommented, Feb 16, 2016

ATM, glob does not support UNC globs, see https://github.com/isaacs/node-glob/issues/74 and https://github.com/isaacs/node-glob/pull/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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Faster way to delete files on a network drive - Super User
Open the Start Menu and in the text box, type cmd.exe and hit Enter (or open the command prompt using your preferred method);...
Read more >
How to delete a mapped network drive from Windows (5 ways)
To remove a drive mapping towards a network folder or FTP site, select it and press Delete on your keyboard. Alternatively, you could...
Read more >
Where Do Files Go When Deleted From a Network Shared ...
With Undelete Server, files deleted from network shares are saved in a Recovery Bin. So, you really can delete a file from the...
Read more >
Can't delete files on NTFS file system - Windows Server
This article describes why can't delete a file or a folder on an NTFS file system volume. It also provides help to solve...
Read more >
Windows 10 user cannot delete file/folder on mapped network ...
The issues is, User03 cannot delete a folder of file. A pop up window comes up with a file is in use etc....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found