I am using gulp
and gulp-shell
. How do I save output to a file (created by gulp
) ?
return gulp.src('.')
.pipe(shell([
'poser install --prefer-source'
]));
I am using gulp
and gulp-shell
. How do I save output to a file (created by gulp
) ?
return gulp.src('.')
.pipe(shell([
'poser install --prefer-source'
]));
Share
Improve this question
edited Nov 13, 2014 at 21:12
Sean Mickey
7,7262 gold badges34 silver badges58 bronze badges
asked Nov 13, 2014 at 21:05
ThomasThomas
5451 gold badge13 silver badges22 bronze badges
4 Answers
Reset to default 3To achieve 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/'));
});
continue with .pipe(gulp.dest('output.file'))
.
Gulp Shell passes files not the output of the mands it runs.
A quick and dirty solution — that is not windows friendly nor gulp based — would be to simply pass the output of the shell mand to a file within the mand itself:
return gulp.src('.')
.pipe(shell([
'poser install --prefer-source > poser-log.txt'
]));
This is obviously only suitable for *nix environments, and doesn't scale well for capturing the output of multiple mands (although you could just append the output from all those mands to the same file).
You could better use run to do this.
gulp.task 'run',->
run ("echo Hello!")
.exec()
.pipe (gulp.dest "G:\\new.txt")
Install needed plugins for this like gulp-run and gulp-exec.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745411152a4626539.html
评论列表(0条)