gulp 清洁工作方式不正确
gulp clean is not working in correct manner
我有这样的目录结构。
dist
|--client
|--assets
|--images
|--bower_components
|--server
|--.bower.json
我正在尝试清理 dist 文件夹,assets/images 文件夹除外。
但是当我在 dryRun 模式下执行此命令时,它不会删除 assets/images 文件。但是禁用它后,它会删除所有文件和文件夹。
gulp.task('clean:dist', () => {
del.sync([
`${paths.dist}/!(.git*|.openshift|Procfile)**`,
`${paths.dist}/client/**`,
`!${paths.dist}/client/assets`,
`!${paths.dist}/client/assets/**`], {
//dryRun: true
});
//console.log('dELETE FIELSE ARE: ' + JSON.stringify(value));
});
使用的常量值为:
${paths.dist} ='dist';
offical del
documentation 声明如下:
The glob pattern **
matches all children and the parent.
So this won't work:
del.sync(['public/assets/**', '!public/assets/goat.png']);
You have to explicitly ignore the parent directories too:
del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']);
在您的情况下,您删除 dist/client/**
,其中包括 dist/client
目录本身。如果您只是忽略 dist/client/assets/**
,dist/client
目录仍会被删除。
您需要明确忽略 dist/client
目录:
gulp.task('clean:dist', () => {
del.sync([
`${paths.dist}/!(.git*|.openshift|Procfile)**`,
`${paths.dist}/client/**`,
`!${paths.dist}/client`,
`!${paths.dist}/client/assets/**`]);
});
我有这样的目录结构。
dist
|--client
|--assets
|--images
|--bower_components
|--server
|--.bower.json
我正在尝试清理 dist 文件夹,assets/images 文件夹除外。
但是当我在 dryRun 模式下执行此命令时,它不会删除 assets/images 文件。但是禁用它后,它会删除所有文件和文件夹。
gulp.task('clean:dist', () => {
del.sync([
`${paths.dist}/!(.git*|.openshift|Procfile)**`,
`${paths.dist}/client/**`,
`!${paths.dist}/client/assets`,
`!${paths.dist}/client/assets/**`], {
//dryRun: true
});
//console.log('dELETE FIELSE ARE: ' + JSON.stringify(value));
});
使用的常量值为:
${paths.dist} ='dist';
offical del
documentation 声明如下:
The glob pattern
**
matches all children and the parent.So this won't work:
del.sync(['public/assets/**', '!public/assets/goat.png']);
You have to explicitly ignore the parent directories too:
del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']);
在您的情况下,您删除 dist/client/**
,其中包括 dist/client
目录本身。如果您只是忽略 dist/client/assets/**
,dist/client
目录仍会被删除。
您需要明确忽略 dist/client
目录:
gulp.task('clean:dist', () => {
del.sync([
`${paths.dist}/!(.git*|.openshift|Procfile)**`,
`${paths.dist}/client/**`,
`!${paths.dist}/client`,
`!${paths.dist}/client/assets/**`]);
});