public EventedStreamStringReader(EventedStreamReader eventedStreamReader) { EventedStreamReader eventedStreamReader1 = eventedStreamReader; if (eventedStreamReader1 == null) { throw new ArgumentNullException(nameof(eventedStreamReader)); } this._eventedStreamReader = eventedStreamReader1; this._eventedStreamReader.OnReceivedLine += new EventedStreamReader.OnReceivedLineHandler(this.OnReceivedLine); }
public NpmScriptRunner( string workingDirectory, string scriptName, string arguments, IDictionary <string, string> envVars) { if (string.IsNullOrEmpty(workingDirectory)) { throw new ArgumentException("Cannot be null or empty.", nameof(workingDirectory)); } if (string.IsNullOrEmpty(scriptName)) { throw new ArgumentException("Cannot be null or empty.", nameof(scriptName)); } string fileName = "npm"; string str = "run " + scriptName + " -- " + (arguments ?? string.Empty); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { fileName = "cmd"; str = "/c npm " + str; } ProcessStartInfo startInfo = new ProcessStartInfo(fileName) { Arguments = str, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, WorkingDirectory = workingDirectory }; if (envVars != null) { foreach (KeyValuePair <string, string> envVar in (IEnumerable <KeyValuePair <string, string> >)envVars) { startInfo.Environment[envVar.Key] = envVar.Value; } } Process process = NpmScriptRunner.LaunchNodeProcess(startInfo); this.StdOut = new EventedStreamReader(process.StandardOutput); this.StdErr = new EventedStreamReader(process.StandardError); }