Get the current file name in gulp.src()

后端 未结 6 756
温柔的废话
温柔的废话 2020-11-28 21:57

In my gulp.js file I\'m streaming all HTML files from the examples folder into the build folder.

To create the gulp task is not difficult:

6条回答
  •  醉酒成梦
    2020-11-28 22:33

    You can use the gulp-filenames module to get the array of paths. You can even group them by namespaces:

    var filenames = require("gulp-filenames");
    
    gulp.src("./src/*.coffee")
        .pipe(filenames("coffeescript"))
        .pipe(gulp.dest("./dist"));
    
    gulp.src("./src/*.js")
      .pipe(filenames("javascript"))
      .pipe(gulp.dest("./dist"));
    
    filenames.get("coffeescript") // ["a.coffee","b.coffee"]  
                                  // Do Something With it 
    

提交回复
热议问题