Gulp generate list of source files and insert into concatenated file

69 Views Asked by At

Using Gulp I'm currently concatenating files from a src glob and outputting the concatenated + uglififed file elsewhere, this is working fine. I also insert a header at the top of the file to let everyone know it was generated by a Gulp script, date, version etc.

What I would like to do is to insert the list of files in the glob into the header, that is subsequently inserted into the concatenated file. Something like this:

Concatenated file:

// Generated by Gulp on [date] version: [version]
// 
// Files in this file:
//
// * some/path/to/file1.js
// * path/to/file2.js
// * path/to/the/third/file.js
// * other/path/to/fourth/file.js
// 
// etc...

I've tried using gulp-tap and I can log the files with various logging tools but I'd like to output the log to a variable that is then inserted in the header of the resulting file.

The purpose of all of this is so that you can open a concatenated file and immediately know the files that are supposed to make up the file (for debugging and general troubleshooting purposes while developing)

0

There are 0 best solutions below