I'm trying to precompile my Handlebars templates during my Grunt tasks, then Lint them along with the rest of my JS files. In Grunt I'm using grunt-contrib-jshint and grunt-contrib-handlebars. The Handlebars templates compile just fine (although they look quite a bit different than the results of precompiling via Handlebars Cl).
Here's an example of the template file output by the grunt-contrib-handlebars task:
this["JST"]["views/handlebars/foo1.hbs"] = function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
However, when the Lint task runs, I get the following error:
['JST'] is better written in dot notation.
I've tried adding predef: ["JST"] to my jshint task in Grunt, but that hasn't helped. I also see another solution online for just suppressing that warning, but that solution seems sub-optimal.
Anyone have any experience with this?
Related
Let's say we have a symbol array of packages packages::Vector{Symbol} = [...] and we want to create a sys image using PackageCompiler.jl. We could simply use
using PackageCompiler
create_sysimage(packages; incremental = false, sysimage_path = "custom_sys.dll"
but without a precompile_execution_file, this isn't going to be worth it.
Note: sysimage_path = "custom_sys.so" on Linux and "custom_sys.dylib" on macOS...
For the precompile_execution_file, I thought running the test for each package might do it so I did something like this:
precompilation.jl
packages = [...]
#assert typeof(packages) == Vector{Symbol}
import Pkg
m = Module()
try Pkg.test.(Base.require.(m, packages)) catch ; end
The try catch is for when some tests give an error and we don't want it to fail.
Then, executing the following in a shell,
using PackageCompiler
packages = [...]
Pkg.add.(String.(packages))
Pkg.update()
Pkg.build.(String.(packages))
create_sysimage(packages; incremental = false,
sysimage_path = "custom_sys.dll",
precompile_execution_file = "precompilation.jl")
produced a sys image dynamic library which loaded without a problem. When I did using Makie, there was no delay so that part's fine but when I did some plotting with Makie, there still was the first time plot delay so I am guessing the precompilation script didn't do what I thought it would do.
Also when using tab to get suggestions in the repl, it would freeze the first time but I am guessing this is an expected side effect.
There are a few problems with your precompilation.jl script, that make tests throw errors which you don't see because of the try...catch.
But, although running the tests for each package might be a good idea to exercise precompilation, there are deeper reasons why I don't think it can work so simply:
Pkg.test spawns a new process in which tests actually run. I don't think that PackageCompiler can see what happens in this separate process.
To circumvent that, you might want to simply include() every package's test/runtests.jl file. But this is likely to fail too, because of missing test-specific dependencies.
So I would say that, for this to work reliably and systematically for all packages, you'd have to re-implement (or re-use, if you can) some of the internal logic of Pkg.test in order to add all test-specific dependencies to the current environment.
That being said, some packages have ready-to-use precompilation scripts helping to do just this. This is the case for Makie, which suggests in its documentation to use the following file to build system images:
joinpath(pkgdir(Makie), "test", "test_for_precompile.jl")
I am inside a directory structure where I have:
--train.lua
--utils
--sample.lua
train.lua has got an import line saying require('sample'), however when running the code Torch7 complains with the message
"module 'sample' not found:No LuaRocks module found for sample
I have tried changing instead to require('utils.sample'), but it still crashes. How to overcome this error?
I do not have the problem you described. Could you post the code in the files?
My three files:
main.lua
require 'utils.sample'
help()
utils/sample.lua
function help()
print("help")
end
I using th main.lua to run the code
I would like to know how to get two packages to compile the same file extension.
I am writing a package that compiles .jsx by looking for certain strings and replacing them. Inside this plugin, I am using isobuild:compiler-plugin#1.0.0:
Plugin.registerCompiler({
extensions: ['jsx']
}, function () {
...
});
The problem is that I cannot use this with mdg's jsx package because that package is also trying to compile .jsx.
Meteor gives me:
While determining active plugins:
error: conflict: two packages included in the app (jsx and my-plugin) are both trying to handle *.jsx
Ideally, I would like jsx plugin to compile the .jsx files first, and then my plugin to compile them again. Any suggestions on how to achieve this? Or can someone point me to any other directions?
I've got a strange behavior of qmake while trying to write smth to another file. I read all possible manuals and searched out the internet but found nothing similiar. Closer to the simplest possible code:
!system(echo 1 > d:\1.txt) {
warning(Cant create a file)
}
It doesn't create a file, and it doesn't show a warning, that means that operation succeded. Another example:
var = test string
file = $$absolute_path(d:\1.txt)
message(Variable: $$var and filename: $$file)
!write_file($$pathBat, pathtowrite) {
warning(Cant create a file)
}
This block produces output:
Project MESSAGE: Variable: test string and filename: d:/1.txt
And nothing is said about the fact the file has not been created.
I've already checked the rights to write to the directory: everything seems fine.
Can anybody help me with this?
UPD:
I've found something else: message($$system(echo 1 > 1.txt)) works fine. And this is what makes me cry, because I really don't understand what is going on.
Huh! I found the solution and it may sounds like buy yourself some brain. I thought, that qmake is launched every time the project file is changed (output of message commands proved my thoughts), but it's not really the way things happen in Qt.
I don't know how exactly, but it parses the .pro file, does only some necessary operations, and as I can see system() (which is going to change some file), write_file() commands doesn't seem to be invoked.
The SOLUTION is so much simple: natively launch qmake using the Build - Launch qmake.
I love TextMate as my editor for all things web, and so I'd like to use a snippet to use it with style.less files to automatically take advantage of the .less way of compiling .css files on the fly using the native
$ lessc {filepath} --watch
as suggested in the less documentation (link)
My (thanks to someone who wrote the LESS TM Bundle!) current TextMate snippet works well for writing the currently opened .less file to the .css file but I'd like to take advantage of the --watch parameter so that every change to the .less file gets automatically compiled into the .css file.
This works well when using the Terminal command line for it, so I am sure it must be possible to use it in an adapted version of the current LESS Command for TextMate since that only invokes the command to compile the file.
So how do I add the --watch flag to this command:?
#!/usr/bin/env ruby
file = STDIN.read[/lessc: ([^*]+\.less)/, 1] || ENV["TM_FILEPATH"]
system("lessc \"#{file}\"")
I assume it should be something like:
#!/usr/bin/env ruby
file = STDIN.read[/lessc: ([^*]+\.less)/, 1] || ENV["TM_FILEPATH"]
system("lessc \"#{file}\" --watch")
But doing so only crashes the TextMate.app.
Did you try running it as a background task?
system("lessc \"#{file}\" --watch &")
I'm guessing you have to put the --watch parameter before the file parameter to lessc, like so:
system("lessc --watch \"#{file}\"")
Take a look at this snippet. It doesn't use the --watch flag, but if you link it to the cmd+s key combination it works perfectly. The snippet will also compile any less files that reference (i.e. #import) the file that was changed. This is great if you have a until.less or something that you include in many different less files, if you change the util.less all the LESS files that depend on it will auto-compile.
Combine that script with the browser refresh script and you have a fairly decent web dev testing routine.