Gulp 从文件中提取文本
Gulp extract text from a file
我想根据每个文件第一行的注释建立一个 table 的内容文件。
我可以毫无问题地获取文件并读取内容,但那只是 returns 文件的缓冲区。
我想检查第一行是否是注释。如果是,则提取该行并将其添加到新文件中。
var bufferContents = through.obj(function(file,enc,cb){
console.log(file.contents);
});
如果文件很大,我会推荐使用惰性模块。
https://github.com/jpommerening/node-lazystream
或者如果指定行长度,您可以设置块大小。
我想根据每个文件第一行的注释建立一个 table 的内容文件。
我可以毫无问题地获取文件并读取内容,但那只是 returns 文件的缓冲区。
我想检查第一行是否是注释。如果是,则提取该行并将其添加到新文件中。
var bufferContents = through.obj(function(file,enc,cb){
console.log(file.contents);
});
如果文件很大,我会推荐使用惰性模块。 https://github.com/jpommerening/node-lazystream
或者如果指定行长度,您可以设置块大小。