Trying to compile my project with a header and footer script that will be at the top and bottom of the output file respectively. Between them I want to include every other script in the project, including going recursively into subfolders.
I tried "..\script\header.js" "..\script\**.js" "..\script\footer.js" And the header is showing up at the top just fine but the footer ends up somewhere in the middle. Is there some way to exclude the footer file from the middle glob so that it only gets appended to the end?
Edit: Running the compiler from cmd in windows with the following command:
java -jar closure.jar --compilation_level "WHITESPACE_ONLY"
--create_source_map "source-map" --output_manifest "manifest"
--output_wrapper_file "output" --js_output_file="..\script.js"
"..\script\header.js" "..\script\**.js" "..\script\footer.js"`
The compiler does process exclusion globs natively. There are a few options to force the order:
Use dependency management. By utilizing either CommonJS or ES6 modules or by using Closure-library's goog.require and goog.provide calls, the compiler can auto sort your input files for you.
Split your files up such that you can construct a glob that does not include your footer.js file.
Use a pre-build tool that understands negation globs to handle your source file set.
Related
I understand that Prettier uses https://github.com/mrmlnc/fast-glob#pattern-syntax for the file/dir/glob element of its CLI.
For my package.json I need a prettier 'one-liner' to examine files which are NOT in the top level apps or modules folders (these folders have other formatting mechanisms).
According to fast-glob I expected to be able to run a command like this to run prettier over files NOT in those folders.
npx prettier '!{apps,modules}/**'
However, this never matches any files. What do I need to change about my syntax?
I have a folder for Octave M-files in C:\\Users\Dropbox\Octave, under which are various subfolders by function categories (normal distribution, chisq...). I just started making those subfolders and they will keep changing (adding, removing, reshuffling) as time goes on.
I would just like to set that folder as root and have Octave search for functions recursively there, just like you set a classpath in Java and JVM searches all folders there.
I used addpath(genpath('C:\\Users\Dropbox\Octave')), but the paths generated are then fixed, not reflecting subsequent subfolder changes.
Shall I add addpath(genpath('C:\\Users\Dropbox\Octave')) to the .octaverc file?
I think there is some confusion here. There are several ways to interact with the path, but for the most part these do not result in permanent changes, unless you save this somehow.
Simply adding a path for an existing octave session will not result in any permanent changes to the usual path that octave initialises at startup. Therefore when you say:
I used addpath(genpath('C:\Users\Dropbox\Octave')), but the paths generated are then fixed, not reflecting subsequent subfolder changes.
this makes no sense, because as soon as you exit your octave session, those added paths should have been gone altogether, and not appear in later octave sessions.
It is more likely that at some point you added these paths, and then used the savepath command, which resulted in your custom paths being added to your .octaverc file.
If that is the case, then yes, you can expect that octave will not "update" what was written in your .octaverc file, unless you call savepath again with an updated path definition.
If you would like the addpath(genpath('C:\Users\Dropbox\Octave')) command you mentioned to be called every time octave starts, so that the current/updated directory structure is loaded, then yes, the best way to do it would be to add that command to your .octaverc file. Make sure you remove the lines in your .octaverc that refer to the previous changes made by savepath. Note that there may be several levels of octaverc files that you need to check (see the relevant page in the manual)
Alternatively, you could simply make sure that this line appears in every script you want to call which intends to make use of those files.
While you may consider this last approach tedious, programmatically it is the most recommended one, since it makes dependencies clear in your code. This is especially important if you ever plan to share your code (and doubly so if you'd like it to be matlab compatible).
PS. All the above mostly applies to matlab too, with the exception that a) matlab's savepath saves path information in a file called pathdef.m, rather than directly in your startup files, and b) matlab uses startup.m instead of .octaverc as startup files. Also, if you don't care about doing this programmatically, matlab provides pathtool, which is a graphical interface for adding / saving directories to the matlab path.
Calling a file resulting from the concatenation (bash: cat ... >> app.js) of the following three files:
/usr/share/ceylon/1.2.0/repo/ceylon/language/1.2.0/ceylon.language-1.2.0.js
modules/com/example/helloworld/1.0.0/com.example.helloworld-1.0.0-model.js
modules/com/example/helloworld/1.0.0/com.example.helloworld-1.0.0.js
with the command nodejs app.js does nothing. The same when used in a web page. How do have I to call that javascript program so that it runs without using require.js ?
Please give the rules how ceylon modules and the run function and other functions contained within translate to javascript and are to be called.
How can I get one javascript file from compilation of several ceylon modules without concatenating them manually or with require.js?
The above is without using google closure compiler.
Given the size of 1.6 MB of the language module, it makes no sense to run ceylon-js without using google closure compiler.
Compiling "ceylon.language-1.2.0.js" alone with google closure compiler results in a lot of warnings.
java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js /usr/share/ceylon/1.2.0/repo/ceylon/language/1.2.0/ceylon.language-1.2.0.js --js_output_file lib-compiled.js
How can I get rid of those warnings?
In what order do I have to chain together files resulting from ceylon-js with the model file and the language file to compile them in advanced mode with google closure compiler for dead code elimination.
These are 3 questions, really.
A Ceylon module is compiled to a CommonJS module. Concatenating the resulting files won't work because each file is on CommonJS format, which is a big function that returns an object with the exported declarations.
You can compile the modules with the --no-module option to get just the generated code, without it being wrapped in CommonJS format. For the language module, you can copy the file and just delete the first line and the last 5 lines.
I do not yet know how to get rid of the warnings you mention in the second question.
And as for the third question, I would recommend putting the language module first, then the rest of the files. If you have any toplevel declarations with the same name in different modules, you'll have conflicts (only the last declaration will remain), even if they're not shared, since they're all in the same module/unit.
Well, I think require.js can run the compilation of the modules to one file and then run the google-closure-compiler, see: http://www.requirejs.org/docs/optimization.html
I'm writing a simple Erlang program that requests an URL and parses the response as JSON.
To do that, I need to use a Library called Jiffy. I downloaded and compiled it, and now i have a .beam file along with a .app file. My question is: How do I use it? How do I include this library in my program?. I cannot understand why I can't find an answer on the web for something that must be very crucial.
Erlang has an include syntax, but receives a .hrl file.
Thanks!
You don't need to include the file in your project. In Erlang, it is at run time that the code will try to find any function. So the module you are using must be in the search path of the VM which run your code at the point you need it, that's all.
For this you can add files to your path when you start erlang: erl -pa your/path/to/beam (it exists also -pz see erlang doc)
Note that it is also possible to modify the path from the application itself using code:add_path(Dir).
You should have a look to the OTP way to build applications in erlang documentation or Learn You Some Erlang, and also look at Rebar a tool that helps you to manage erlang application (for example starting with rebar or rebar wiki)
To add to Pascal's answer, yes Erlang will search for your files at runtime and you can add extra paths as command line arguments.
However, when you build a project of a scale that you are including other libraries, you should be building an Erlang application. This normally entails using rebar.
When using rebar, your app should have a deps/ directory. To include jiffy in your project, it is easiest to simply clone the repo into deps/jiffy. That is all that needs to be done for you to do something like jiffy:decode(Data) in your project.
Additionally, you can specify additional include files in your rebar.config file by adding extra lines {erl_opts, [{i, "./Some/path/to/file"}]}.. rebar will then look for file.so using that path.
Let's say that i have file /home/foo/myfile without extension. Is there option to add syntax setting into this file? In vim it's :set syntax=javascript. I know that in Sublime you can set default syntax color.
There's similar question Changing default syntax based on filename but there you set specific filename. I need to set it in file itself, since i have a lot of different files without extension.
The package ApplySyntax should be able to do what you want.
ApplySyntax is a plugin for Sublime Text 2 and 3 that allows you to
detect and apply the syntax of files that might not otherwise be
detected properly. For example, files with the .rb extension are
usually Ruby files, but when they are found in a Rails project, they
could be RSpec spec files, Cucumber step files, Ruby on Rails files
(controllers, models, etc), or just plain Ruby files. This is actually
the problem I was trying to solve when I started working on this
plugin.
Set your rules/filenames in the ApplySyntax.sublime-settings file:
// "rules" is a list (array) of checks that you want to make against
the file in the current view. A rule is either a regular expression
or a function. If using a regular expression, you can specify
whether you want it tested against the "file_name" or the first
line of the file (think shebangs and xml files). If the rule is a
function, you must provide the path to the file containing the
function and the name of the function to call. When this function is
called, the "file_name" will be passed to it as the only argument.
You are free to do whatever you want in your function, just return
True or False.
you can do this on the fly through the command menu (on OSX cmd+shift+p, windows ctrl+shift+p) then type what you need (e.g. javascript) and it will come up in the list set syntax: JavaScript.
Sublime will remember this until you close the file