Created
December 5, 2016 16:10
-
-
Save surrealroad/f31527b1e51cb05d532ae4a88f859473 to your computer and use it in GitHub Desktop.
JXA Scriptlet to allow importing .js files in the same folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ObjC.import('Foundation') | |
var app = Application.currentApplication() | |
app.includeStandardAdditions = true | |
var path = app.pathTo(this); | |
var workflowFolder = $.NSString.alloc.initWithUTF8String(path).stringByDeletingLastPathComponent.js + '/'; | |
//https://github.com/dtinth/JXA-Cookbook/wiki/Importing-Scripts | |
var jslibPath = workflowFolder + "script.min.js" | |
var fm = $.NSFileManager.defaultManager; | |
var contents = fm.contentsAtPath(jslibPath); // NSData | |
contents = $.NSString.alloc.initWithDataEncoding(contents, $.NSUTF8StringEncoding); | |
eval(ObjC.unwrap(contents)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment