bolt-cep icon indicating copy to clipboard operation
bolt-cep copied to clipboard

About evalFile

Open YukiWorks432 opened this issue 6 months ago • 1 comments

evalFile currently runs script files using ExtendScript's $.evalFile. However, $.evalFile sometimes throws an obscure error: "Can not convert to". This appears to be a bug in $.evalFile. I found that the same problematic file does not cause the error if you read its contents with Node.js fs.readFileSync and pass the text to csi.evalScript.

For this reason, I suggest changing evalFile to use csi.evalScript (by reading the file with fs and passing the contents) instead of calling $.evalFile.

YukiWorks432 avatar Oct 02 '25 08:10 YukiWorks432

like,

export const evalFile = (file: string) => {
  const string = fs.readFileSync(file, "utf8");
  if (!string || string.length === 0)
    throw new Error(`No script found at ${file}`);
  return evalES(string, true);
};

YukiWorks432 avatar Oct 02 '25 08:10 YukiWorks432