private static bool TryGetVersion(string directory, string command, out string version) { version = null; if (string.IsNullOrEmpty(command)) { return(false); } if (!Directory.Exists(directory)) { return(false); } var output = UTinyShell.RunInShell(command, new ShellProcessArgs() { ExtraPaths = directory.AsEnumerable(), ThrowOnError = false }); if (!output.Succeeded) { return(false); } version = output.CommandOutput; return(true); }
/// <summary> /// Runs the given command in the OS shell (cmd on Windows, bash on Mac/Linux). /// </summary> public static bool RunInShell(string command, ShellProcessArgs processArgs, bool outputOnErrorOnly = true) { var output = UTinyShell.RunInShell(command, processArgs); if (!output.Succeeded) { Debug.LogError($"{UTinyConstants.ApplicationName}: {output.FullOutput}"); } else if (!outputOnErrorOnly) { Debug.Log($"{UTinyConstants.ApplicationName}: {output.FullOutput}"); } return(output.Succeeded); }
public static Process RunNodeNoWait(DirectoryInfo workingDirectory, string jsProgram, string arguments, DataReceivedEventHandler outputReceived = null, DataReceivedEventHandler errorReceived = null) { // Install modules as needed if (!RunNpmInstall(workingDirectory)) { return(null); } // Run the program return(UTinyShell.RunNoWait("node", $"{jsProgram ?? "index.js"} {string.Join(" ", arguments)}", new ShellProcessArgs() { WorkingDirectory = workingDirectory, ExtraPaths = TinyPreferences.NodeDirectory.AsEnumerable() }, outputReceived, errorReceived)); }