Search code examples
npmglobdel

How to ignore .git folder when using NPM del


This is probably stupid easy, but I'm having serious difficulties finding the answer. I want to delete everything in a folder except the .git folder. I'm calling it as such:

return del([
    buildTo + "/**",
    "!" + buildTo + "/.git"
], { force: true });

I've tried that and a few other things to no avail. The .git folder keeps getting deleted. What's the correct way to not delete it?


Solution

  • Turns out this was stupid easy. I forgot the "/*" at the end and didn't even need the ignore:

    return del([
        buildTo + "/**/*"
    ], { force: true });