Copy link to clipboard
Copied
I thought this little bash compiler script may be of use to some here... :clinking_beer_mugs:
A little background:
I've yet to try and understand setting up ExtendScript projects using TypeScript and the tsc compiling options, instead on larger scripts I split them into multiple files/modules and use ExtendScript Preprocessor Directives to include everything.
This works great for me but is a pain for end users to install. In the past, I would either export to JSXBIN or painstakingly copy and paste everything into a single JSX file. Both of these methods have drawbacks. JSXBIN isn't human readable meaning you have to dig around in the repo to see how things work, plus it's just not very "open source-y". And copying and pasting by hand always leads to me forgetting something.
Enter computers...
How it works:
The script reads through the supplied .jsx script file looking for any 'include' statements and replaces them with contents from that file.
./escompile.sh sample_jsx_project/src/script.jsx > sample_jsx_project/compiledScript.jsx
What can it detect?
This script tries to process include and includepath statements just as the ExtendScript engine does.
include file
Inserts the contents of the named file into the output at the location of this statement.
#include "../include/lib.jsxinc"
//@include "../include/file.jsxinc"
If the file to be included cannot be found, the script throws an error.
includepath path
One or more paths that the #include statement should use to locate the files to be included. The semicolon (;) separates path names.
If a #include file name starts with a slash (/), it is an absolute path name, and the include paths are ignored. Otherwise, the script attempts to find the file by prefixing the file with each path set by the #includepath statement.
#includepath "include;../include"
#include "file.jsxinc"
//@includepath "include;../include"
//@include "file.jsxinc"
Multiple #includepath statements are allowed; the list of paths updates each time an #includepath statement is executed.
Please note, I'm not a bash programmer, but it's been working great for me so far. Please let me know of any issues you run in to.
1 Correct answer
I tried it on some scripts to get all the includes into one file and it really saved me time.
Explore related tutorials & articles
Copy link to clipboard
Copied
I tried it on some scripts to get all the includes into one file and it really saved me time.

