Search code examples
gulpgulp-concatgulp-uglify

gulp Read all file names from folder and store in some file


I am using "gulp-filenames" to get the file name, I followed the documentation what I found from this site. It doesn't help :(

Please see below code

var filenames = require("gulp-filenames");

gulp.src('/*.js'))
   .pipe(filenames("javascript"));

filenames.get("javascript")

Basically I want to store all file name in one file.

=======================

INPUT

  • Folder

    1. myfile.js
    2. myfile1.js

=====================

EXPECTED OUPTPUT

  • Folder

    1. myfile.js
    2. myfile1.js
    3. javascript (Which contains the file name for example myfile.js and myfile1.js with path)

Solution

  • Finally I got the answer, with the "gulp-filelist", I can get all filename.

    Below are the code fore reference.

    gulp.src(['../Scripts/Include/JavaScript/DatePicker.js', 
    '../Scripts/Include/JavaScript/DatePicker_Plugins.js'])
          .pipe(filelist('filelist.json'))
          .pipe(gulp.dest("./dist"));