diff --git a/Apprise/Apprise.csproj b/Apprise/Apprise.csproj index 4b6064e8..2fbc8d31 100644 Binary files a/Apprise/Apprise.csproj and b/Apprise/Apprise.csproj differ diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index 5813cec4..2065a842 100644 Binary files a/BasicNodes/BasicNodes.csproj and b/BasicNodes/BasicNodes.csproj differ diff --git a/BasicNodes/JavascriptExecutor.cs b/BasicNodes/JavascriptExecutor.cs index 474773d7..1de0a316 100644 --- a/BasicNodes/JavascriptExecutor.cs +++ b/BasicNodes/JavascriptExecutor.cs @@ -1,5 +1,6 @@ using FileFlows.Plugin; using Jint; +using Jint.Runtime; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; @@ -71,13 +72,28 @@ internal class JavascriptExecutor }) .SetValue("Logger", args.Logger) .SetValue("Variables", args.Variables) - .SetValue("Flow", args); + .SetValue("Flow", args) + .SetValue(nameof(FileInfo), new Func((string file) => new FileInfo(file))) + .SetValue(nameof(DirectoryInfo), new Func((string path) => new DirectoryInfo(path))); ; foreach (var arg in execArgs.AdditionalArguments) engine.SetValue(arg.Key, arg.Value); var result = int.Parse(engine.Evaluate(tcode).ToObject().ToString()); return result; } + catch(JavaScriptException ex) + { + // print out the code block for debugging + int lineNumber = 0; + var lines = execArgs.Code.Split('\n'); + string pad = "D" + (lines.ToString().Length); + args.Logger.DLog("Code: " + Environment.NewLine + + string.Join("\n", lines.Select(x => (++lineNumber).ToString("D3") + ": " + x))); + + args.Logger?.ELog($"Failed executing script [{ex.LineNumber}, {ex.Column}]: {ex.Message}"); + return -1; + + } catch (Exception ex) { args.Logger?.ELog("Failed executing function: " + ex.Message + Environment.NewLine + ex.StackTrace); diff --git a/BasicNodes/ScriptNode.cs b/BasicNodes/ScriptNode.cs index 35ef98fd..723cfab4 100644 --- a/BasicNodes/ScriptNode.cs +++ b/BasicNodes/ScriptNode.cs @@ -45,7 +45,8 @@ public class ScriptNode:Node var execArgs = new JavascriptExecutionArgs { Args = args, - Code = Code + "\n\n" + entryPoint + //Code = ("try\n{\n\t" + Code.Replace("\n", "\n\t") + "\n\n\t" + entryPoint + "\n} catch (err) { \n\tLogger.ELog(`Error in script [${err.line}]: ${err}`);\n\treturn -1;\n}").Replace("\t", " ") + Code = (Code + "\n\n" + entryPoint).Replace("\t", " ").Trim() }; if (script.Parameters?.Any() == true) diff --git a/ChecksumNodes/ChecksumNodes.csproj b/ChecksumNodes/ChecksumNodes.csproj index cb8ea1a9..03be6753 100644 Binary files a/ChecksumNodes/ChecksumNodes.csproj and b/ChecksumNodes/ChecksumNodes.csproj differ diff --git a/CollectionNodes/CollectionNodes.csproj b/CollectionNodes/CollectionNodes.csproj index 43ea1685..9c9a9031 100644 Binary files a/CollectionNodes/CollectionNodes.csproj and b/CollectionNodes/CollectionNodes.csproj differ diff --git a/DiscordNodes/DiscordNodes.csproj b/DiscordNodes/DiscordNodes.csproj index c1bdccc4..eea47e5e 100644 Binary files a/DiscordNodes/DiscordNodes.csproj and b/DiscordNodes/DiscordNodes.csproj differ diff --git a/EmailNodes/EmailNodes.csproj b/EmailNodes/EmailNodes.csproj index 512a51ef..3ddd1cd0 100644 Binary files a/EmailNodes/EmailNodes.csproj and b/EmailNodes/EmailNodes.csproj differ diff --git a/Emby/Emby.csproj b/Emby/Emby.csproj index dc732e38..d6403b0f 100644 Binary files a/Emby/Emby.csproj and b/Emby/Emby.csproj differ diff --git a/FileFlows.Plugin.dll b/FileFlows.Plugin.dll index cefd757e..455a30d3 100644 Binary files a/FileFlows.Plugin.dll and b/FileFlows.Plugin.dll differ diff --git a/FileFlows.Plugin.pdb b/FileFlows.Plugin.pdb index bb30c076..44551ad2 100644 Binary files a/FileFlows.Plugin.pdb and b/FileFlows.Plugin.pdb differ diff --git a/Gotify/Gotify.csproj b/Gotify/Gotify.csproj index fb4255a6..6fa9a420 100644 Binary files a/Gotify/Gotify.csproj and b/Gotify/Gotify.csproj differ diff --git a/ImageNodes/ImageNodes.csproj b/ImageNodes/ImageNodes.csproj index d854cc03..001b523b 100644 Binary files a/ImageNodes/ImageNodes.csproj and b/ImageNodes/ImageNodes.csproj differ diff --git a/MetaNodes/MetaNodes.csproj b/MetaNodes/MetaNodes.csproj index ce4c259d..0a33ab4d 100644 Binary files a/MetaNodes/MetaNodes.csproj and b/MetaNodes/MetaNodes.csproj differ diff --git a/MusicNodes/MusicNodes.csproj b/MusicNodes/MusicNodes.csproj index 543948fc..02074fde 100644 Binary files a/MusicNodes/MusicNodes.csproj and b/MusicNodes/MusicNodes.csproj differ diff --git a/Plex/Plex.csproj b/Plex/Plex.csproj index 7a4c7019..f75b55fe 100644 Binary files a/Plex/Plex.csproj and b/Plex/Plex.csproj differ diff --git a/VideoNodes/VideoNodes.csproj b/VideoNodes/VideoNodes.csproj index 020aa236..2d4ebfc0 100644 Binary files a/VideoNodes/VideoNodes.csproj and b/VideoNodes/VideoNodes.csproj differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll b/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll index 5f5e3654..cfd54f00 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll and b/build/utils/PluginInfoGenerator/FileFlows.Plugin.dll differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb b/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb index d4378d9f..6e7c4767 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb and b/build/utils/PluginInfoGenerator/FileFlows.Plugin.pdb differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll index 65e99194..3bb7ae78 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll and b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.dll differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb index e0dec801..ecfa8c8a 100644 Binary files a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb and b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.pdb differ diff --git a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.xml b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.xml index fc1a7bbd..c911fd39 100644 --- a/build/utils/PluginInfoGenerator/FileFlows.ServerShared.xml +++ b/build/utils/PluginInfoGenerator/FileFlows.ServerShared.xml @@ -816,6 +816,13 @@ Script Service interface + + + Get a script + + The UID identifying the script + the script + Get the code for a script @@ -839,6 +846,13 @@ an instance of the script service + + + Get a script + + The UID identifying the script + the script + Get the code for a script diff --git a/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll b/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll index 1e94d65b..bb5a5711 100644 Binary files a/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll and b/build/utils/PluginInfoGenerator/PluginInfoGenerator.dll differ diff --git a/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb b/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb index f6ef8869..9e55a794 100644 Binary files a/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb and b/build/utils/PluginInfoGenerator/PluginInfoGenerator.pdb differ