I have the following output:
gulp.task('log', function () {
spawn('git', ['log', '-20', '--pretty=format:"%h - %an, %ai : %s <br\>'], {stdio: 'inherit'});
});
And I want to save it to a file. How can I achive that?
I am new to gulp, tried to use this:
gulp.task('log', function() {
require('fs').writeFileSync('myGitLog.txt', spawn('git', ['log', '-20', '--pretty=format:"%h - %an, %ai : %s <br\>'], {stdio: 'inherit'}))
});
but it put '[object Object] into the files.
My other approach was this:
gulp.task('log', function() {
const text = spawn('git', ['log', '-20', '--pretty=format:"%h - %an, %ai : %s <br\>'], {stdio: 'inherit'});
return file('myGitLog.txt', text, {src: true})
.pipe(gulp.dest('./'));
});
But this gave me the following error:
TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
at Function.Buffer.from (buffer.js:161:9)
Thank you in advance.
Found a possible solution using shell task:
gulp.task('log', shell.task([
'git log -20 --pretty=format:"%h - %an, %ai : %s <br/>" > "valami.txt"'
]));