简体   繁体   English

不能与Gulp一起使用vinylPaths del

[英]Cannot use vinylPaths del with gulp

I have the following gulp task, basically what it does is: 我有以下gulp任务,基本上它的作用是:

  • compile all .styl files 编译所有.styl文件
  • put the result in theme/app folder 将结果放入theme/app文件夹
  • minify all file in theme/app folder 缩小theme/app文件夹中的所有文件
  • concatenate all file in folder theme/app folder to a single file 将文件夹theme/app文件夹中的所有文件合并为一个文件
  • add some license information to the file 在文件中添加一些许可证信息
  • save result in folder theme 将结果保存在文件夹theme
  • delete all files in theme/app folder 删除theme/app文件夹中的所有文件

I cannot make work the last step, I need to delete all files in theme/app . 我无法进行最后一步,需要删除theme/app所有文件。 I have not specific error, what could could be wrong in my script and how to solve it? 我没有特定的错误,我的脚本中可能有什么错误以及如何解决?


   gulp.task('_release-theme:compile', function () {
        gulp.src([
            'app/**/*.styl',
            '!app/**/**mixins**.styl',
            '!app/**/**variables**.styl',
        ])
        .pipe(stylus({
            compress: false,
            use: nib()
        }))
        .pipe(gulp.dest('theme/app'))
        .pipe(cleanCSS())
        .pipe(concat('theme.css'))
        .pipe(header(fs.readFileSync('licenses/app.txt', 'utf8')))
        .pipe(gulp.dest('theme/'))
        .pipe(vinylPaths(del['theme/app/**/*'])); // problem here
    });

del is a function. del是一个函数。 Your object property access del['theme/app/**/*'] makes no sense here. 您的对象属性访问del['theme/app/**/*']在这里毫无意义。

Instead listen for the end event in your stream and then delete the files using rimraf : 而是侦听流中的end事件,然后使用rimraf删除文件:

var rimraf = require('rimraf');

gulp.task('_release-theme:compile', function (done) {
    gulp.src([
        'app/**/*.styl',
        '!app/**/**mixins**.styl',
        '!app/**/**variables**.styl',
    ])
    .pipe(stylus({
        compress: false,
        use: nib()
    }))
    .pipe(gulp.dest('theme/app'))
    .pipe(cleanCSS())
    .pipe(concat('theme.css'))
    .pipe(header(fs.readFileSync('licenses/app.txt', 'utf8')))
    .pipe(gulp.dest('theme/'))
    .on('end', function() {
      rimraf('theme/app/**/*', done);
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM