Use $outfolder in Node.js

Post Reply
Meik
Newbie
Posts: 4
Joined: Tue Mar 26, 2024 11:02 am

Use $outfolder in Node.js

Post by Meik »

Hello,
I'm new to Node.js and I'm trying to develop a Node.js-Script that runs AppleScript which then runs a JSX-Script. That works just fine. The Problem is, that I need to use $outfolder inside of that JSX-Script, so I need to read it via Node to pass it on. I can't seem to find a way to get that Outfolder-Path in Node. Can someone help? Am I missing something obvious?
Meik
Newbie
Posts: 4
Joined: Tue Mar 26, 2024 11:02 am

Re: Use $outfolder in Node.js

Post by Meik »

Seems like I've found a solution to my Problem. I just create a temporary folder with:

Code: Select all

let outfolder = tmp.dirSync().name;
And pass it on to AppleScript and JSX. Seems to work.
A new problem that occured, is that I also need to pass the Job to AppleScript and JSX so that Photoshop can use a JSX Script to process and save that Job File.

I pass the job (and the outfolder and many more variables) to AppleScript with this variable:

Code: Select all

let jobPathString = await job.get(AccessLevel.ReadWrite);
AppleScript then runs a JSX Script that processes the File via Photoshop and saves it at that outfolder path.
After that I receive back the path to that file as a return in my Node.js-Script.
So how can I use

Code: Select all

job.sendToData(Connection.Level.Success)
on that exact file instead of my "primary" job?

I've tried this:

Code: Select all

let newJob = await job.createChild(outfiles[0]);
await newJob.sendToData(Connection.Level.Success);
await job.log(LogLevel.Info, "newJob sent to data");
await job.sendToNull();
await job.log(LogLevel.Info, "job sent to null");
fs.unlinkSync(outfiles[0]);
but as soon as I try to send the primary job to null, it crashes saying:
Method is not allowed at this time. Have you called any sendTo method already? Error: Method is not allowed at this time. Have you called any sendTo method already?
If I don't send it to null, the new Job is sent to success, but the primary job of course doesn't get deleted.
Can anyone help?
Post Reply