【发布时间】:2015-04-11 21:21:14
【问题描述】:
例如,我正在处理一个想要调试某个文件的 gulp 任务,并且我想在控制台中读取它。
不管是通过流还是通过简单任务。 我尝试打印乙烯基对象的内容...但没有任何好的结果
gulp.task('task', function(){
console.log( gulp.src('path/to/file.txt').content.toString() );
});
function sendTo(res) {
return through(
function write(data) { // this will be called once for each file
res.write(data.contents);
},
function end() { // this will be called when there are no more files
res.end()
}
);
}
gulp.task('task', function(res){
gulp.src('path/to/file.txt')
.pipe(sendTo(res));
});
或尝试使用fs node module 进行操作,结果相同...
fs.readFile('path/to/file.txt', {encoding: 'utf-8', flag: 'rs'}, function(e, data) {
if (e) return console.log(e);
console.log(data);
});
打印文件内容的任何想法?
【问题讨论】:
-
@gopinathshiva 这正是我尝试做的:[
标签: javascript node.js gulp