bolt-cep
bolt-cep copied to clipboard
About evalFile
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.
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);
};