0

I have designed a gulp task for linting of .ts files present in my project. When I run it, it shows correct output on the prompt, but I am not sure how to redirect that output to a file so it can be printed so that I can handover the complete file to developer to correct the code accordingly.

my task looks like :

gulp.task('lint', function() {
   gulp.src("src/**/**/*.ts")
     .pipe(tslint({
        formatter: "codeFrame",
        configuration: "./tslint.json"
    }))
    .pipe(tslint.report({
        configuration: {},
        rulesDirectory: null,
        emitError: true,
        reportLimit: 0,
        summarizeFailureOutput: true
    }))
    .pipe(gulp.dest('./Dest/reports'))
});

Could someone please suggest how do I achieve this.

Mark
  • 143,421
  • 24
  • 428
  • 436
Vinay Verma
  • 533
  • 1
  • 6
  • 28
  • Perhaps https://stackoverflow.com/questions/26396947/node-gulp-process-stdout-write-to-file will be helpful. – Mark Sep 28 '17 at 17:29

1 Answers1

1

See redirect via tee for some good examples of redirecting the stdout to a file. It could be as simple as

gulp lint | tee logfile.txt

With that you'll get both the output in the terminal as per usual and a copy in a file, that will be created for you if necessary. You don't say what terminal you are using though. if that doesn't work perhaps:

gulp lint 1> logfile.txt

See bash redirecting if you are using bash shell. Or SO: bash redirecting with truncating.

The linked question also has info on stderr if you need that.

Also for a quick way to copy output to the clipboard in Powershell:

gulp lint | clip
gulp lint | scb             (doesn't add an extra newline at the end)

See pbcopy same as clip for macOS.

In general, see pbcopy alternatives on Windows

Mark
  • 143,421
  • 24
  • 428
  • 436
  • Thanks for the suggestion Mark, but I needed to write some code within the script only and not mention anything on cmd at the run time. Well, this [Link](https://www.npmjs.com/package/gulp-tslint-jenkins-reporter) helped me out here – Vinay Verma Sep 29 '17 at 08:00