Gulp how to save output to file
4 answers
For this I use gulp-exec
.
gulp.task("git_log", [], function(){
var options = {
continueOnError: false, // default = false, true means don't emit error event
pipeStdout: true, // default = false, true means stdout is written to file.contents
customTemplatingThing: "test" // content passed to gutil.template()
};
var reportOptions = {
err: false, // default = true, false means don't write err
stderr: true, // default = true, false means don't write stderr
stdout: false // default = true, false means don't write stdout
};
return gulp.src("somefile.txt")
.pipe(exec("pwd", options))
.pipe(exec.reporter(reportOptions))
.pipe(gulp.dest('build/'));
});
+2
source to share
Gulp Shell transfers files not the output of the commands it runs.
A quick and dirty solution not compatible with Windows and gulp is to simply pipe the output of a shell command to a file inside the command itself:
return gulp.src('.')
.pipe(shell([
'composer install --prefer-source > composer-log.txt'
]));
This is obviously only suitable for * nix environments and doesn't scale enough to collect the output of multiple commands (although you can just add the output from all of those commands to the same file).
0
source to share