Thanks for the reply.
Unfortunately I didn't make myself clear.
What I am trying to do is have one piece of code that I can develop outside of Hazel, but then also call from Hazel once debugged.
My testing shows that in the case of JavaScript, the script is loaded and run before then calling the hazelProcessFile() entry point.
I have a self-executing function that is run each time that Hazel runs the script and I would like to place some logic in the "iife" that switches based on whether Hazel is running. This happens before entering hazelProcessFile().
Here is an outline of the code:
- Code: Select all
/* anonymous self-executing function permits to run this in script editor etc */
/* We need to determine if we are running in Hazel, so that `theFile` can be set */
(() => {
const thisApp = "Script Editor" // I want to dynamically detect Hazel or not Hazel here
if (thisApp !== 'Hazel') { // don't run in Hazel to prevent hazelProcessFile() running twice
// logic goesj here to set `theFile` and any `inputAttributes`
hazelProcessFile(fullPath, inputAttributes));
} else { //Hazel
// do nothing here
}
})();