递归删除文件夹的内容但保留文件夹

Delete folder’s contents recursively but keep folder

我希望以递归方式删除目录的所有内容(一个文件除外)但保留文件夹本身。为此,我编写了此任务:

gulp.task('clean:documentation', function () {
    del([
        'documentation.typography/**',
        '!documentation.typography/.gitignore'
    ]);
});

不幸的是,它删除了整个文件夹。这个任务有什么问题?我如何更新才能删除 documentation.typography 除了 文件的 .gitignore 中的所有内容?

解决方案是更改 glob:

gulp.task('clean:documentation', function () {
    del([
        'documentation.typography/**/*',
        '!documentation.typography/.gitignore'
    ]);
});