-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
140 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { ObservableProcess } from "./observable-process" | ||
export { Result } from "./result" | ||
export { SearchableStream } from "./searchable-stream" | ||
export { start } from "./start" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** Provides the results of running the process */ | ||
export interface Result { | ||
/** the code with which the process has ended */ | ||
exitCode: number | ||
|
||
/** whether the process was manually terminated by the user */ | ||
killed: boolean | ||
|
||
/** full output on the STDOUT stream */ | ||
stdOutput: string | ||
|
||
/** full output on the STDERR stream */ | ||
errOutput: string | ||
|
||
/** combined output from STDOUT and STDERR */ | ||
combinedOutput: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import stringArgv from "string-argv" | ||
import { ObservableProcess } from "./observable-process" | ||
|
||
/** The options that can be provided to Spawn */ | ||
export interface SpawnOptions { | ||
cwd?: string | ||
env?: NodeJS.ProcessEnv | ||
} | ||
|
||
/** starts a new ObservableProcess with the given options */ | ||
export function start(command: string | string[], args: SpawnOptions = {}): ObservableProcess { | ||
// determine args | ||
if (!command) { | ||
throw new Error("start: no command to execute given") | ||
} | ||
let argv: string[] = [] | ||
if (typeof command === "string") { | ||
argv = stringArgv(command) | ||
} else if (Array.isArray(command)) { | ||
argv = command | ||
} else { | ||
throw new Error("start: you must provide the command to run as a string or string[]") | ||
} | ||
const [runnable, ...params] = argv | ||
|
||
// start the process | ||
return new ObservableProcess({ | ||
cwd: args.cwd || process.cwd(), | ||
env: args.env || process.env, | ||
params, | ||
runnable, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { createObservableProcess, ObservableProcess } from "../../src/observable-process" | ||
import { ObservableProcess } from "../../src/observable-process" | ||
import { start } from "../../src/start" | ||
|
||
export function startNodeProcess(code: string): ObservableProcess { | ||
return createObservableProcess(["node", "-e", code]) | ||
return start(["node", "-e", code]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.