public async Task <ProcessRunResults> ExecuteAsync( string arguments, CancellationToken cancellationToken) { var processUtils = new ProcessUtils(); const string npm = "npm.cmd"; string npmPath = await processUtils.FindProgramAsync(npm, cancellationToken).ConfigureAwait(false); string directoryWithScript = Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NodeScript"); try { var result = await processUtils.RunProcessAsync(npmPath, $"install {directoryWithScript}").ConfigureAwait(false); } catch (ProcessRunException ex) { Console.WriteLine(ex.ProcessStandardOutput); throw; } string executablePath = "node.exe"; executablePath = await processUtils.FindProgramAsync(executablePath, cancellationToken).ConfigureAwait(false); string executeArgs = $"{directoryWithScript}\\index.js {arguments}"; Console.WriteLine($"Calling: {executablePath} {executeArgs}"); ProcessRunResults processRunResults = await processUtils.RunProcessAsync(executablePath, executeArgs, cancellationToken).ConfigureAwait(false); return(processRunResults); }
public async Task <ProcessRunResults> ExecuteAsync( string arguments, CancellationToken cancellationToken) { var sb = new StringBuilder(); sb.Append($"{PythonScriptPath.EncloseQuotes()} "); sb.Append(arguments); string finalArguments = sb.ToString(); string executablePath = "python.exe"; var processUtils = new ProcessUtils(); executablePath = await processUtils.FindProgramAsync(executablePath, cancellationToken).ConfigureAwait(false); Console.WriteLine($"Calling: {executablePath} {finalArguments}"); ProcessRunResults processRunResults = await processUtils.RunProcessAsync(executablePath, finalArguments, cancellationToken).ConfigureAwait(false); return(processRunResults); }