This was briefly discussed at the end of this thread.
Well I have now update the init script again, this time with a full JXA Build process in Atom! Here’s a brief list of features:
Commands:
jxa:execute - builds your project and executes it. All errors are displayed in View>Developer>Developer Tools
jxa:compile - builds your project into a *.scpt file
jxa:compileApp - builds your project into a *.app
Building
You will notice I use the word “build” a lot. This is because the script also implements a command include
. You can use include as follows:
include(“my/directory/myFile.js”)
When a project is “built” the above statement will be replaced with the contents of myFile.js.
It is also compatible with relative file paths such as:
include("…/…/other/directory/myFile.js")
How to use:
- Install atom
- Open atom
- GoTo Atom > Init script…
- GoTo https://github.com/sancarn/JXA-Compile/blob/master/src/init.js
- Copy my code and paste it in your init.coffee.
- Rename init.coffee to init.js
- Close atom
- Open atom
- Open a JXA script in Atom.
Now press cmd+shift+p
to bring up the command pallet and type, for example, jxa:execute
. The currently open JXA file should be executed.
See it in action:
I made a little youtube video demonstrating the current capabilities of JXA-Build:
Note: In this video I also use a custom keymap which can be found here
Currently known bugs
For some reason when I use keymap to map the commands to keys e.g.:
'.editor':
'cmd-k':'jxa:compile'
'shift-cmd-k':'jxa:compileApp'
'cmd-u':'jxa:execute'
the commands don’t execute the first time they are called. This may lead to nothing happening when using your keyboard shortcut. Example.
EDIT: This is a bug created by how Atom interprates keyboard shortcuts. See here for details.
Conclusions
If you find any more bugs please don’t hesitate to contact me.
##I would strongly advise saving before using any scripts.
I just noticed compile errors are currently not supported. So please be advised, save scripts before attempting to compile/execute scripts.
Finally, if anyone wants to include these commands in an atom package, you are more than welcome to! I myself am not comfortable enough with making packages yet… Which is one of the reasons why I made the include() commands in the first place! Otherwise I would just use node!