Intellij external tool does not output stdout logs from Sass - intellij-idea

i'm using sass for my project, in intellij using sass plugin.
i want to be able to launch sass --watch from within intellij, to be able to get console feedback, with clickable lines.
i've setup an external tool in intellij with:
Program: D:\ruby\bin\sass.bat
Parameters: --watch $/FileRelativeDir$
Working directory: $ProjectFileDir$
it does compile my scss to css without problems but the stdout from sass are not reported in the intellij console. i only get stderr.
if i have an error, after a while, i get a bunch of lines at once.
so i'm guessing there is some kind of buffering happening.
redirecting 1>&2 does not solve the problem.
Here's what i get in logs
Sass::Compiler#on_updating_stylesheet callback is deprecated and will be removed in a future release. Use Sass::Compiler#on_updated_stylesheet instead, which is run after stylesheet compilation.
d:/ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.11/vendor/fssm/lib/fssm/support.rb:40: Use RbConfig instead of obsolete and deprecated Config.
and here's what i get using the same command in a console :
Sass::Compiler#on_updating_stylesheet callback is deprecated and will be removed in a future release. Use Sass::Compiler#on_updated_stylesheet instead, which is
run after stylesheet compilation.
>>> Sass is watching for changes. Press Ctrl-C to stop.
error src/main/www/css/test.scss (Line 3690: Invalid CSS after "...'); IE6 & IE7*": expected "{", was "/")
error src/main/www/css/test.scss (Line 80: Invalid CSS after "...unimplemented *": expected "{", was "/")
d:/ruby/lib/ruby/gems/1.9.1/gems/sass-3.1.11/vendor/fssm/lib/fssm/support.rb:40: Use RbConfig instead of obsolete and deprecated Config.
(yes i have an intended error in my scss file to produce logs)

found it thanks to default ruby arguments in intellij ruby projects
you need to pass ruby the following options :
-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)
and that did the trick
Program : D:\ruby\bin\ruby.exe
Parameters : -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) d:/ruby/bin/sass -g --watch $/FileRelativeDir$
Working directory : $ProjectFileDir$

Related

Error building Angular Library : Cannot read property 'toString' of undefined

I have created a custom library to be used in my main angular application...
However, when I try to build the library using ng build lib-name I am getting the error:
**Cannot read property 'toString' of undefined**.
I could not find an exact solution to get rid of this error.
Any suggested actions?
Some reference information:
Angular CLI: 8.3.5
Node: 10.16.3
OS: win32 x64
Angular:
...
Package Version
#angular-devkit/architect 0.803.5
#angular-devkit/core 8.3.5
#angular-devkit/schematics 8.3.5
#schematics/angular 8.3.5
#schematics/update 0.803.5
rxjs 6.4.0
For me, I get this because I prefer inline templates and styles but I forget to include -s -t flags when using ng generate (especially in lib projects where the global inline settings in angular.json don't seem to stick?).
After I do an ng generate I delete the foo.html and foo.scss files to avoid going into a trance while alt-tabbing 20 times in 5 seconds.
Then, I change templateUrl to template: <p>foo works</p> (note: replace the single quotes from the url string with the template's tickmarks).
I then often forget to change the styleUrl['foo.scss'] to styles:[``] and then this error message pops up. This is quite a lame error message from a great tool but I thinks it has something to do with the opacity of webpack.

PixiJS for Haxe won't import - Type Not Found error in IntelliJ

I'm trying to run the most basic PixiJS for Haxe sample program, but IntelliJ gives a Type Not Found error.
The failing code:
package ;
import pixi.core.Application;
The error message:
Main.hx:3: characters 7-28 : Type not found : pixi.core.Application
I think the issue is PixiJS-specific, as when I follow the same install-and-import steps for other Haxe modules (eg flambe, flixel) they behave as expected. I've tried with both 4.7.1 and 4.5.5, and as both global and project-specific libraries (separately).
(I hybridized several screenshots to save space)
When running from the console, using:
> haxe -main Main -lib pixijs -js output.js
Everything seems to compile (running the compiled code results in a PIXI is not defined error which is a seperate issue).
UPDATE 1, how I'm adding the dependency:
After executing haxelib install pixijs, I follow these steps:
UDPATE 2, the config being run:
If you can't get it working in the dependencies section you could try adding the haxelibs pixijs externs src/ folder as an additional sources root in Project Structure -> Modules -> (module name) -> Sources. That's how it worked for me:

Configuring Erlang plugin for Intellij

I am trying to set-up an Erlang project in IntelliJ 15. I am running windows.
I have built Rebar. trying escript.exe "//rebar_path//" --version returns the version number. Erlang also works on command line. In Settings->Other-settings->Erlang External tools I have the address of rebar file and IntelliJ detects the version number alright.
For my hello-world Erlang App, I have added an Erlang console application which runs fine and gives me
D:/Program Files/erl7.2.1\bin\erl" -pa E:/Documents/Projects/Erlang_test/out/production/Erlang_test -pa E:/Documents/Projects/Erlang_test
at the top. However attempting to call the functions gives me:
exception error: undefined function hello:hello2/0
It's as if compilation does not happen. I also tried setting up an "Erlang Rebar" Run configuration with compile as the command. It outputs:
*"D:\Program Files\erl7.2.1\bin\escript.exe"
E:\Documents\Projects\rebar_source\rebar c*
at the top, followed by the error:
escript: Error executing 'D:\Program': 193
What am I doing wrong?
update: I tried adding the rebar.cmd as an external tool to run it before the run configuration. After doing some research, I tried adding a rebar.config file with:
{sub_dirs, ["src" ] }.
to match the project structure.
Running the tool with compile on its own outputs: (configuration page screenshot)
==>src (compile)
==> Erlang_test (compile)
I was expecting to get: Compiled src/hello.erl but I neither get that, nor do I see any bean files created anywhere; and if I try running hello:hello() in the "Erlang console" run configuration gives me:
exception error: undefined function hello:hello2/0

How to setup WebStorm / IntelliJ so the output from Grunt console has links into the files, in the same way a FileWatcher that calls tsc would do

Using IntelliJ/WebStorm if I run tsc from a FileWatcher, my compile errors are linked to the files in the editor, such that if I double-click on a compiler error, it opens that file and takes me to the offending line of code.
However if I run Grunt, either via the integrated Grunt console, or via a FileWatcher, the compile errors do not have links and I have to manually open the file and goto the offending line number.
Is there any way to get the compile errors comming from Grunt integrated as links, like the TypeScript FileWatcher's invocation of tsc does?
When running Grunt as a file watcher, you can set up filters to make links clickable. You can use existing filters as example: open your file watcher settings, press Output Filters..., open the filter settings and copy the regular expression specified there. See http://www.jetbrains.com/webstorm/webhelp/add-filter-dialog.html
In Webstorm 8, it is not possible to apply regular expression filters on Grunt console output.
The way to go, as mentioned by lena, is to call Grunt directly via an External tool entry, and set up appropriate regex filters, such as:
For grunt-ts:
$FILE_PATH$\($LINE$,$COLUMN$\):.*
For grunt-tslint:
...$FILE_PATH$\[$LINE$,\s$COLUMN$\]:.*
Also see my comment above regarding a caveat for grunt-tslint in some environments.
I believe the '>>' added by grunt-typescript is throwing it off. Try grunt-ts (disclaimer : one of the authors) which is tested with webstorm https://github.com/grunt-ts/grunt-ts
I noticed in Webstorm 9, the built-in Grunt console was filtering/linking on typescript compile errors with grunt-typescript. I am not sure if this is a recent change or not, but it was linking this for example,
So, I went into grunt-tslint/node_modules/tslint/build/formatters, and copied proseFormatter.js to ./myproseFormatter.js. Then I tweaked it so the tslint output format would match the compile error format, by replacing square brackets with parens, and removing the whitespace between line and column number. Finally, I referenced my custom formatter in my gruntfile tslint config by adding the formatter and formattersDirectory properties:
tslint: {
options: {
configuration: grunt.file.readJSON('tslint.json'),
formatter: 'myprose',
formattersDirectory: './'
},
all: {
src: [ 'app/**/*.ts' ]
}
}
and it worked!

getting more information from phantomjs "SyntaxError: Parse error" message

I have a long script that was not written by me. When i run it I get:
phantomjs file.js
SyntaxError: Parse error
i checked out the manual and --help, and the best i could came up with was:
phantomjs --debug=yes file.js
(irrelevant debug statement from CookieJar)
SyntaxError: Parse error
Is there any better way to get at least a line number? or any hint at all?
Run the file with node. If there is a parse error it will report it.
If the file is valid, then node will also try to run it, which will fail if your script depends on something not available in your node environment. So you'll have to ignore any runtime errors.
For example, given hello-world.js:
// Say Hello World twice
for (var i=0; i<2; i++) {
console.log("Hello World") );
}
Run it with node:
node hello-world.js
Output:
/home/someone/somewhere/hello-world.js:3
console.log("Hello World") );
^
SyntaxError: Unexpected token )
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Your file.js contains an invalid syntax. You should check it with a syntax validator. An online tool which I have created can be one possible solution, check out http://esprima.org/demo/validate.html.
Getting More Information From PhantomJS
The next version of PhantomJS (presumably it will be 1.9.8, whatever comes after 1.9.7) will output errors like this:
SyntaxError: Parse error
http://localhost:9000/scripts/49e8b4f4.vendor.js:8
So that's slightly more useful than the current message.
Unfortunately there are no nightly builds for PhantomJS, so at this time you will need to compile your own version of master if you want to try this.
Debugging Minified files
If you are working with a minified file, often the line number won't be very helpful, and often debugging the un-minified file won't give you the parse error.
To solve this, once you get phantomjs to give you the name of the file, you can use the online demo of Esprima to get an actual parse of your JavaScript code:
http://esprima.org/demo/parse.html
From there, you can enter strategic line breaks to isolate the actual error.
Lint Tools are Sub-optimal for this use-case
A lint tool like jslint or jshint are more opinionated than a real parser, so if you are looking for a very specific syntax error, I would recommend using a real parser, since it will check only for code validity, and not opinionated styling guidelines. I'm not implying lint tools don't have value, just that they won't be as helpful for solving this type of problem.
You can also use syntax linters like jslint or jshint
I received SyntaxError: Parse error while trying to require a custom minified jquery.
I found the solution was to add a blank line to the bottom of jquery.min.js.
Hopefully this helps someone. Using PhantomJS 1.9.7.
I use a simple shell script that will run Phantom normally if no parse errors are found, otherwise it will display the errors. It runs the script through node, checks for SyntaxError in the output and then re-runs node to the terminal if there are errors. It passes all the command line arguments along to Phantom.
Failure mode for this method is if your node parser is significantly different from your Phantom parser. Mine are close enough that it's never been a problem.
usage: ./debug.sh --myArg1 val1 --myArg2 val2
debug.sh:
ERROR=$(node myscript.js 2>&1 >/dev/null | grep "SyntaxError")
if [ "$ERROR" = "" ]; then
echo "No parse errors, running script..."
# run the script with Phantom and pass all the args to it
phantomjs accession.js $*
else
echo "*********************************************************"
echo "********* There are parse errors in the script: *********"
echo "*********************************************************"
# show the errors by running again but not redirecting
node accession.js
fi
I did have the same issue, but none of the solutions worked for me.
I figured that the issue was probably an unsupported syntax by PhantomJS's webkit, since my page was working correctly in current browsers' versions.
What I did was finding out which webkit version PhantomJS was using, for 1.9.* it's here, 34.534.
Now we have to find the Chromium version using the same webkit, or close to it, in here (for Mac).
Ended up going with the Mac OSX 267668 and installed it.
Loaded the same URL as PhantomJS, and here it was, a real Uncaught SyntaxError: Unexpected token with a full stack trace.
Hope that helps.