2016-04-08 15 views
1

我有以下一飲而盡任務,基本上它的作用是:不能vinylPaths德爾使用與一飲而盡

  • 編譯所有.styl文件
  • 結果放在theme/app文件夾
  • 縮小在theme/app所有文件文件夾
  • 串接在文件夾theme/app文件夾中所有文件到單個文件
  • 添加一些許可證信息的文件
  • 保存導致文件夾theme
  • 刪除theme/app文件夾

我不能讓工作中的最後一步,所有的文件,我需要刪除theme/app所有文件。 我沒有具體的錯誤,我的腳本中可能會出現什麼錯誤以及如何解決它?


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 
    }); 

回答

2

del是一個函數。你的對象屬性訪問del['theme/app/**/*']在這裏沒有意義。

而不是聽你流中的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); 
    }); 
}); 
+0

謝謝,我不知道rimraf! – GibboK