Last active
April 10, 2019 09:49
-
-
Save jasonrhodes/5286526 to your computer and use it in GitHub Desktop.
Include the minified version at the top of any of our .jsx script files and then you can include files from adobe_scripts/lib just by calling Libraries.include("subdir/myscript")
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
// Assumes that your script is somewhere within a folder called "adobe_scripts" and | |
// that you store your includable files relative to `adobe_scripts/lib/` | |
// indexOf polyfill from https://gist.github.com/atk/1034425 | |
[].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1;}); | |
var Libraries = (function (libPath) { | |
return { | |
include: function (path) { | |
if (!path.match(/\.jsx$/i)) { | |
path = path + ".jsx"; | |
} | |
return $.evalFile(libPath + path); | |
} | |
}; | |
})($.fileName.split("/").splice(0, $.fileName.split("/").indexOf("adobe_scripts") + 1).join("/") + "/lib/"); | |
// Minified version, to include at the top of any .jsx script file | |
/** | |
* Libraries.include(path) -- path must be relative to adobe_scripts/lib/ | |
* See: https://gist.github.com/jasonrhodes/5286526 | |
*/ | |
[].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1;}); | |
var Libraries=function(a){return{include:function(b){return b.match(/\.jsx$/i)||(b+=".jsx"),$.evalFile(a+b)}}}($.fileName.split("/").splice(0,$.fileName.split("/").indexOf("adobe_scripts")+1).join("/")+"/lib/"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey I'm trying to use this with Illustrator and keep getting the error:
Error 21: Undefined is not an object.
Line 6 -> var Libraries = (function(libpath){
Thank you so much for you time and no pressure, but do you know what's causing this?