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

Ignore pattern doesn't work outside working directory #52

Closed
Palpie opened this issue Feb 15, 2016 · 6 comments
Closed

Ignore pattern doesn't work outside working directory #52

Palpie opened this issue Feb 15, 2016 · 6 comments
Assignees

Comments

@Palpie
Copy link

Palpie commented Feb 15, 2016

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
@schnittstabil schnittstabil self-assigned this Feb 15, 2016
@schnittstabil
Copy link
Collaborator

@Palpie Thanks for reporting, that is a globbing issue (isaacs/node-glob#248).

@schnittstabil
Copy link
Collaborator

Using cwd may be a possible workaround:

del(['test/assets/**', '!test/assets', '!test/assets/goat.png'], {
    cwd: '/build',
    dryRun: true
}) // …

@Palpie
Copy link
Author

Palpie commented Feb 16, 2016

It works fine with cwd and it actually made my real code look nicer!

Thanks!

@kevinmamaqi
Copy link

I am experiencing the same problem, but CWD does not work in my case/ I have the following code:

// delete task
gulp.task( 'delete', function() {
  return del([
      '../../../project/app/myfolder/**',
      '!../../../project/app/myfolder',
      '!../../../project/app/myfolder/json/**',
    ],
    {
      force: true,
    });
});

And also tried:

// delete task
gulp.task( 'delete', function() {
  return del([
      '/myfolder/**',
      '!/myfolder',
      '!/myfolder/json/**',
    ],
    {
      cwd: '../../../project/app',
      force: true,
    });
});

How can I make it wrong, is there a mistake in the code?

@Ch2x
Copy link

Ch2x commented Nov 24, 2020

@kevinmamaqi I ran into the same problem,how did you solve it in the end

@kevinmamaqi
Copy link

@Ch2x I think a did a shell script at the end.

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