Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JXA Scriptlet to allow importing .js files in the same folder
var app = Application.currentApplication()
app.includeStandardAdditions = true
var path = app.pathTo(this);
var workflowFolder = $.NSString.alloc.initWithUTF8String(path).stringByDeletingLastPathComponent.js + '/';
var jslibPath = workflowFolder + "script.min.js"
var fm = $.NSFileManager.defaultManager;
var contents = fm.contentsAtPath(jslibPath); // NSData
contents = $.NSString.alloc.initWithDataEncoding(contents, $.NSUTF8StringEncoding);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment