Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy the existing docs for exec* methods so they're accessible to users #46

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion packages/devcmd/src/process/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,54 @@
import { ProcessExecutor } from "./ProcessExecutor";

export const { execInTty, execPiped, execPipedParallel, execToString } = new ProcessExecutor(console);
const DefaultProcessExecutor = new ProcessExecutor(console);

/**
* Executes a process and throws an exception if the exit code is non-zero.
* Outputs (stdout/stderr) of the process are sent to our stdout/stderr.
*
* @param processInfo Information about the process to execute
* @returns A promise that resolves on success and rejects on error
*
* @example
* <caption>Running ping 127.0.0.1 on localhost</caption>
* ```
* try {
* await execPiped({
* command: 'ping',
* args: ['127.0.0.1'],
* });
* } catch {}
* ```
*/
export const execPiped = DefaultProcessExecutor.execPiped;

/**
* Executes multiple processes in parallel and throws an exception if the exit code is non-zero.
* Outputs (stdout/stderr) of the processes are sent to our stdout/stderr. Can also take an array
* of {@link ProcessInfo}, since arrays are compatible with the object type indexed by integers.
*
* @param processMap A map linking process ids to {@link ProcessInfo} instances
* @returns A promise that resolves on success and rejects on error
*
*
* @example
* <caption>Printing node and npm version to the console</caption>
* ```
* await execPipedParallel({
* nodeVersion: {
* command: "node",
* args: ["-v"],
* },
* npmVersion: {
* command: "npm",
* args: ["--version"],
* },
* });
* ```
*/
export const execPipedParallel = DefaultProcessExecutor.execPipedParallel;

export const execInTty = DefaultProcessExecutor.execInTty;
export const execToString = DefaultProcessExecutor.execToString;

export { ProcessExecutor, ProcessInfo } from "./ProcessExecutor";