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.
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
Related
In WebStorm don't work Pug's argument "--pretty"
HTML file looks like:
But I want:
Please advise what to do?
I do not want to write on the command line
pug --watch --pretty ./pug/ --out ./html/
I want to make the default setting.
Works fine for me when using the following setup:
Arguments: $FileName$ --pretty --out $ProjectFileDir$/html
Output paths to refresh: $ProjectFileDir$/html/$FileNameWithoutExtension$.html
the file in your screenshot doesn't seem to be produced by a file watcher - it's location doesn't match the output directory in your file watcher settings
Consider the following minimal example:
$ yarn init
$ yarn add gulp gulp-cli --dev
and a minimal gulpfile.js file
var gulp = require('gulp');
gulp.task('default', function() {
console.log('Hello World!');
});
If I run ./node_modules/gulp-cli/bin/gulp.js I get the following output
[ ] Using gulpfile /tmp/test/gulpfile.js
[ ] Starting 'default'...
Hello World!
[ ] Finished 'default' after 152 μs
The timestamps are not displayed in my console. However, if I copy the content of the console and paste it into an editor of my choice, then I can see the timestamps. Hence, my terminmal must be part of the problem. I was wondering how I can debug it. Is there something special about the console output of gulp-cli and the timestamps? I already toggled through several fonts without luck. I also tried as shells bash and zsh. I'm using gnome-terminal.
This seems to be a bug/feature of the solarized theme. AFAIK the solarized theme won't be fixed and mocha and all the other console writers won't change their behavior just because of one theme.
As a starter have a look here or just google for gulp and solarized.
This is a bug in the solarized dark theme. It is in fact still an open issue: Color fix needed?
The best fix for this is imo to use the patched version found in mbadolato/iTerm2-Color-Schemes:
link to the actual "Solarized Dark - Patched.itermcolors"
Problem: I'm learning ES6 through playing around with the code. I found that it's quite annoying to rebuild and restart the server every time I made any changes.
Goal: I want the changes that I saved to be reflected on the browser, without having to manually rebuild, and restart the server. What's the simplest way to do that?
Background:
The current script configuration in the package.json file is as below.
"scripts": {
"babel": "babel --presets es2015 js/main.js -o build/main.bundle.js",
"start": "http-server -p 9000"
},
I hope this is clear. Thank you!
I believe you must be using gulp tasks to run your project. If so, browser-sync + gulp.watch() is the best option for this. Below is what working for me, add something like below to your gulp task .js file. Whenever you change and save your es6 source code, it will automatically build and refresh the browser.
var gulp = require('gulp');
var browser = require('browser-sync').create();
// your default task goes here that should add "watch-changes" as dependency
// watch changes in js and html files
gulp.task('watch-changes', function() {
browser.init({
// initiate your browser here, refer browser-sync website
});
gulp.watch(
['build/main.bundle.js', 'webapp/**/*.html'],
browser.reload);
});
Check here neat example.
Refer browser-sync website and npm gulp-watch task
I'm using pug/jade watcher with the following "Output paths to refresh": $ProjectFileDir$\html\$FileNameWithoutExtension$.html. This should save the output in /html but for some reason it saves it next to the jade file.
You need changing Jade watcher arguments accordingly:
Arguments: $FileName$ --pretty --out $ProjectFileDir$/html
Working directory: $FileDir$
Output paths to refresh: $ProjectFileDir$/html/$FileNameWithoutExtension$.html
I have a simple gulpfile.js file with the next content:
var gulp = require("gulp");
gulp.task("test", []);
gulp.task("default", []);
But when I try to run "test" task with command gulp test it always runs only the "default" task. If I remove the "default" task it says Task default is not in your gulpfile
How can I run my custom task from the console?
Ok, I have realized what was the problem. Windows command line doesn't see additional command line arguments, which I passed to the gulp. To resolve this problem we need to go to the registry and fix HKEY_CLASSES_ROOT\Applications\node.exe\shell\open\command key.
Originally the value was C:\Program Files (x86)\nodejs\node.exe" "%1". We need to add the %* symbols to the end of the string. Thus, our key value should look like this:
"C:\Program Files (x86)\nodejs\node.exe" "%1" %*