Comments (4)
Hey @JMichaelTX,
No worries I love to discuss this stuff. π
I'm guessing that it works properly when you force it to use a Javascript syntax in the language selector in the lower right.
I use the idleberg extension too, it's awesome. But I don't use it for JXA anymore - these days I just use it for Applescript. If I'm understanding it right, it's providing two things for JXA files ( recognized by .jxa, .jxainc, or .js extensions ):
- a JXA language syntax ( for syntax coloring ) that is based on Javascript's ( and there is nothing more for it to add ).
- a set of commands for running, compiling and bundling JXA scripts ( with toolbar button(s) )
You can get both of these, plus the missing JS language support, by treating your JXA scripts as regular Javascript:
- name your jxa scripts with the .js extension ( not .jxa )
- include a shebang at the top; one of:
#!/usr/bin/env node-jxa
# (if you're using it)#!/usr/bin/env osascript -l JavaScript
- use the Code Runner extension to run your JXA scripts - it regards shebangs by default.
The Code Runner extension actually includes support for running AppleScript files (shebang would work too), but we still need the idleberg extension for AS syntax coloring.
from node-jxa.
You can get both of these, plus the missing JS language support, by treating your JXA scripts as regular Javascript:
Thanks, John. I really appreciate your help.
I have not been able to install your node-jxa yet (I need instructions using npm to install), but using:
#!/usr/bin/env osascript -l JavaScript
with Code Runner seems to work OK, except for access to the Application.currentApplication()
object.
I'll post another issue to address that.
One question here: Is it possible to associate the ".jxa" extension with JavaScript in VSC? I'd like to continue using it to denote my JXA scripts (vs my pure JavaScripts)?
Many thanks.
from node-jxa.
hey @JMichaelTX..
node-jxa installation
Ah I see.. node-jxa has to be installed globally, maybe that's why it's not working.
I should have included the npm installation command in addition to the yarn version.. (done just now). The command using npm is :
npm install -g node-jxa # ( `-g` can also be `--global`)
adding jxa file association for javascript
Yep you can do this by adding this line to your settings.json (you probably want to use your user settings, not workspace settings):
"files.associations": { "*.jxa":"javascript" },
Correction.. see next comment
It's a bit unpredictable though, since the idleberg extension also contributes a .jxa association. I just tested it and recognized it as Javascript the first time, but as 'Javascript for Automation (JXA)' the second time. I hope there's a way to force it to choose the former but I don't know how at the moment.
from node-jxa.
Quick update here @JMichaelTX .. It looks like my "file.associations" line in my setting.json was deleted by the settings sync extension that I'm using.. so I put it back permanently.
With that bit in my config, it does select Javascript for .jxa files repeatably, even though I still have the idleberg extension installed. I'm editing my last post accordingly.
from node-jxa.
Related Issues (20)
- remove node-debug-jxa, since the βdebug switch can be used in all the same ways
- show error on spurious args
- Add a headsup to README about filesystem limitations HOT 1
- add a tip to simply include `debugger` to debug script
- add this tut to resources (includes tip on JXA with Alfred)
- propose link to node-jxa at these cookbook spots
- research browserify alternatives to work around limitations (i.e. fs access)
- Issue with the JXA Application.currentApplication() Object HOT 6
- wrap entire script in a try/catch, and $.exit(1) on error
- add a test confirming that the added code is valid & doesn't cause errors
- move all limitations in the README to a dedicated section
- Feature Request - Add commandline option to generate compiled .scpt file from source HOT 2
- not clear how to use example.js HOT 2
- chmod +x the example script in git
- Add info on installing dependencies to README
- The 2.1.2 release on NPM includes a reference to a developer-local directory (and doesn't correspond to the Github tag) HOT 2
- dependency graph error
- First
- Can I import Node-Jxa and use JXA stuff in Node?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-jxa.