I am trying to write a custom task in my MSBuild file to compress some js files with Google Closure Compiler. I downloaded the ClosureCompiler.dll and ClosureCompiler.tasks files from the site and have kept them in a folder on my m/c. I added the below lines in my csproj file
<Import Project="C:\Projects\Closure\ClosureCompiler.tasks" />
<Target Name="AfterBuild">
<ItemGroup>
<JS Include="test.js" />
</ItemGroup>
<ClosureCompiler CompilationLevel="SIMPLE_OPTIMIZATIONS" SourceFiles="#(JS)" SourceExtensionPattern="\.js$" TargetExtension=".min.js" />
</Target>
The test.js file is kept on the root of my project files. I do not want to include the optional ApiUrl since I want to compress files locally using ClosureCompiler.dll. The ClosureCompiler.tasks file is
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="ClosureCompiler" AssemblyFile="C:\Projects\Closure\ClosureCompiler.dll" />
</Project>
However when I try to compile the project, it gives me an error:
Compilation Failed: test.js, Reason: Object reference not set to instance of an object
Can anyone help as to what is the issue or what am I doing wrong?
I ran into the same issue and it is a bug in the custom task code. It is because the API is returning an error and the custom code is not checking to see if the API returns an error.
It will check
compiledSource.SelectSingleNode("//compileCode").InnerText
That will throw an object not reference for .InnerText if there is no node named compiledCode. You need to check for errors in the response first.
if (compiledSource.SelectSingleNode("//error") != null)
throw new Exception(compiledSource.SelectSingleNode("//error").InnerText);
Go to
http://closure-compiler.appspot.com/home
And see if you can paste "Anything" in. You may have reached your hourly limit. VS2010 WILL throw this message if the aforementioned happens and causes an error. So...it is One thing that will cause it.
Related
I'm trying to use the "node-tesseract-ocr" module with electron to perform some basic image-to-text translations, but I'm having issues that I cannot seem to figure out, for the life of me. I'm using the exact same code as provided in the example (seen here: https://www.npmjs.com/package/node-tesseract-ocr), except I've changed the "lang" parameter for the configuration to the name of my custom .traineddata file. I've installed Tesseract manually alongside this, and have set the PATH variables for Tesseract ("C:\Program Files\Tesseract-OCR" and "C:\Program Files\Tesseract-OCR\tessdata"), and have placed the .traineddata file inside of the \tessdata folder.
Here's the error:
Command failed: tesseract "./screen.png" stdout -l mc --oem 1 --psm 3
Error opening data file C:\Program Files\Tesseract-OCR/tessdata/mc.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'mc'
Tesseract couldn't load any languages!
Could not initialize tesseract.
I have no idea why the slashes swap midway through the path to the .traineddata file; I'm assuming this is the issue, but I have no idea how to fix this, as it seems to be an issue with Tesseract itself.
Did I install an incorrect version or something? (I installed Tesseract using "tesseract-ocr-w64-setup-v5.2.0.20220712.exe" from "https://digi.bib.uni-mannheim.de/tesseract/", as suggested by "https://medium.com/quantrium-tech/installing-and-using-tesseract-4-on-windows-10-4f7930313f82").
Everything works perfectly fine when using "eng" as the language, except the characters are not always read properly (since I'm attempting to read characters from a game, rather than handwriting/a standard English font, which is why I need the custom .traineddata file to work).
Any help is appreciated.
I used the installation from https://github.com/UB-Mannheim/tesseract/wiki and it seems to work now. Not sure why the other installation was bugged, but oh well.
I have a react-native project written in JavaScript for which I'm trying to run the sonar-analysis.
I have a sonar server set-up for this and system where I'm trying to run the analysis has Sonar-scanner, npm and all other project dependencies installed.
However, When I run the sonar analysis on the react-native project I'm getting following error:
ERROR: Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
at org.sonar.java.JavaClasspath.init(JavaClasspath.java:59)
at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:281)
at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:141)
at org.sonar.java.JavaSquid.<init>(JavaSquid.java:83)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:83)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:111)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Had the same issue, and was wondering where did java files came in to a node project. Then by doing a file search I found several java classes in the node_modules folder. Was able to move forward by excluding them in the sonar properties file.
sonar.exclusions=test/**, node_modules/**
The error message is actually pretty clear:
Please provide compiled classes of your project with sonar.java.binaries property
Your project includes Java files, which cannot be analyzed without also providing their compiled .class files. You must either first compile (and feed the class file location into analysis) or exclude the .java files from analysis.
Currently trying to get a Kotlin "Hello, World" to compile to JS via the command line. I've followed the tutorial:
https://kotlinlang.org/docs/tutorials/javascript/getting-started-command-line/command-line-library-js.html
I'm seeing the Javascript files being generated, but I'm missing the kotlin.js file that I would expect to see per:
https://kotlinlang.org/docs/tutorials/javascript/kotlin-to-javascript/kotlin-to-javascript.html
The first few lines of the generated JS files read:
if (typeof kotlin === 'undefined') {
throw new Error("Error loading module 'sample-library'. Its dependency
'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to
'sample-library'.");
}
so it's clear that the it's meant to be run with a file that instantiates kotlin. Any ideas why I'm not seeing it? I'm following the tutorial exactly as written. I'm using the latest version of the compiler from homebrew, which is 1.1.2.2
As described here, yes, you'll need to include kotlin.js before you can run your own Kotlin code. This file contains the Kotlin runtime and standard library.
If you're doing this from the command line, you can find kotlin.js in the lib folder of the compiler, inside kotlin-stdlib-js.jar (which you can just open as a regular .zip file).
I have a minimized file in production, with a an error handler that logs the errors, as well as the source map that was generated when I minified the file, however I have no way to map the errors to my source file since the errors are in a log and do not occur in a chrome or firefox where minified files and sourcemaps are easily consumed. Is there an app or a tool that will convert the error reporting from the minified file using the source map I have generated to the location in the original unminified files? So to be completely clear I have
dist.min.js
which is made up of several js files concated and then minified with uglify.js. I have
dist.min.js.map
which is the mapfile generated when the uglify minified the file. What I need to do is take the error
ERROR: Uncaught TypeError: Cannot call method 'indexOf' of undefined, dist.min.js:1
"TypeError: Cannot call method 'indexOf' of undefined
at distmin.js:1:21815 at ab.event.dispatch (dist.min.js:3:25564)
at q.handle (dist.min.js:3:22314)"
and figure out where that error is actually happening in my original source code. I know how to use sourcemaps with Chrome, but is there an external tool that will allow me to manually enter the line and column and bring up the location in my source code?
You can use mozilla's source-map library to reverse-map to the original positions, as follows:
var smc = new SourceMapConsumer(rawSourceMap); // <-- put map in there
console.log(smc.originalPositionFor({ // <-- plug positions here
line: 2,
column: 28
}));
Output is similar to:
{
source: 'http://example.com/www/js/two.js',
line: 2,
column: 10,
name: 'n'
}
The example is straight from Mozilla's documentation. The same library is used to generate the source-maps in uglifyjs (links to the Mozilla project when mentioning source-map generation).
Since there wasn't a GUI tool already built for this, I quickly built one based on Electron and the Mozilla Source-Map library that #tucuxi pointed out.
You can find it at its GitHub page: https://github.com/kriserickson/sourcemap-translator.
Uglify.js has a thing named source map for such functionality. Please use following flag with command:
--source-map yoursource.min.js.map
Whole command looks like:
uglifyjs yoursource.js -o yoursource.min.js --sourcemap yoursource.min.js.map
More info:
http://tarantsov.com/WorkflowThu/source-maps-with-coffeescript-and-uglify-js/
locally my application.js is fine. But when running my tests on tddium, the javascript does not work. After dumping page.error_messages (from capybara-webkit) at the failing spec, i see:
{:line_number=>26654, :message=>"SyntaxError: Parse error", :source=>"http://127.0.0.1:35634/assets/application.js"}
So, because the file is compiled (but not compressed) at runtime on tddium. I have to get it to see whats going wrong there.
When its compiled at runtime, i think it does not reside in public/assets but in cache, right? How can i access this file?
Thanks for help - cheers!
Run
bundle exec rake assets:precompile
And see if you get any errors.
Usually you'll get an error message telling you what file and line number the error is at.
The error message says that you have an error on line 26654 in the application.js file. If you don't get any error messages during precompiling, you can take a look at the application.js, line 26654 in the public/assets directory after precompiling is done.
(Tddium co-founder, here.)
It's possible (but not yet documented) to attach arbitrary build artifacts to a Tddium build so that they're included in the list of files at the end of the build report page.
Take a look at:
https://github.com/solanolabs/tddium/blob/master/lib/tddium/agent/tddium.rb#L66
You can use that with a post-build task to save whatever you need.
http://docs.tddium.com/getting-started/post-build-tasks
Contact us at support#tddium.com if you need specific help.