Gulp: How to write text into a file? Not from a source file.

Created on 7 Mar 2014  路  1Comment  路  Source: gulpjs/gulp

I am wondering if it is possible to write something into a file? Instead of using gulp.src('glob').pipe(gulp.dest('target/'))?

The thing is i have some text generated while the task is running, and i'd like to write those thing into a file. For consistency purpose, i am asking if there is a gulp plugin to do this? Instead of fs?

Most helpful comment

Use node's fs module

var fs = require('fs');
var gulp = require('gulp');

gulp.task('taskname', function(cb){
  fs.writeFile('filename.txt', 'contents', cb);
});

>All comments

Use node's fs module

var fs = require('fs');
var gulp = require('gulp');

gulp.task('taskname', function(cb){
  fs.writeFile('filename.txt', 'contents', cb);
});
Was this page helpful?
0 / 5 - 0 ratings