Skip to content

Commit

Permalink
30 convenience methods for ProcChildProcess; dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
j50n committed May 25, 2023
1 parent 36fa45f commit b693d33
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 30 deletions.
4 changes: 2 additions & 2 deletions legacy/deps-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "https://deno.land/std@0.188.0/testing/asserts.ts";
export * from "https://deno.land/std@0.189.0/testing/asserts.ts";
export * from "https://deno.land/x/[email protected]/mod.ts";
export * from "https://deno.land/std@0.188.0/fmt/colors.ts";
export * from "https://deno.land/std@0.189.0/fmt/colors.ts";
4 changes: 2 additions & 2 deletions legacy/deps.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "https://deno.land/std@0.188.0/async/mod.ts";
export * from "https://deno.land/std@0.188.0/io/mod.ts";
export * from "https://deno.land/std@0.189.0/async/mod.ts";
export * from "https://deno.land/std@0.189.0/io/mod.ts";
2 changes: 1 addition & 1 deletion legacy/examples/pushiterable/example-of-pushiterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Answer, Question } from "./common-json-defs.ts";
import * as proc from "../../mod.ts";
import { asynciter } from "https://deno.land/x/[email protected]/mod.ts";
import { blue, red } from "https://deno.land/std@0.188.0/fmt/colors.ts";
import { blue, red } from "https://deno.land/std@0.189.0/fmt/colors.ts";

/**
* This demonstrates sending objects to and receiving objects from a child process
Expand Down
2 changes: 1 addition & 1 deletion legacy/runners/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isWindows } from "https://deno.land/std@0.188.0/_util/os.ts";
import { isWindows } from "https://deno.land/std@0.189.0/_util/os.ts";

export const LINESEP: string = (() => {
if (isWindows) {
Expand Down
2 changes: 1 addition & 1 deletion legacy/runners/handlers/bytes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.189.0/testing/asserts.ts";
import * as proc from "../../mod.ts";

Deno.test({
Expand Down
2 changes: 1 addition & 1 deletion legacy/runners/utility.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BufReader, BufWriter } from "../deps.ts";
import * as path from "https://deno.land/std@0.188.0/path/mod.ts";
import * as path from "https://deno.land/std@0.189.0/path/mod.ts";

export const DEFAULT_BUFFER_SIZE = 4096;

Expand Down
2 changes: 1 addition & 1 deletion legacy/tests/line-split.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.189.0/testing/asserts.ts";
import * as proc from "../mod.ts";

Deno.test({
Expand Down
2 changes: 1 addition & 1 deletion legacy/tests/piped.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.189.0/testing/asserts.ts";
import * as proc from "../mod.ts";

Deno.test({
Expand Down
41 changes: 21 additions & 20 deletions src/proc-readable-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,6 @@ export function run(

return p;
}
// /**
// * Run a process.
// * @param cmd The command.
// * @param options Options.
// * @returns A child process instance.
// */
// export function run(
// cmd: string,
// options?: { args?: string[]; cwd?: string },
// ): ProcChildProcess {
// const p = new ProcChildProcess(
// new Deno.Command(cmd, {
// args: options?.args,
// cwd: options?.cwd,
// stdout: "piped",
// }).spawn(),
// );

// return p;
// }

export class ProcReadableStream<R> implements ReadableStream<R> {
constructor(protected readonly source: ReadableStream<R>) {
Expand Down Expand Up @@ -415,4 +395,25 @@ export class ProcChildProcess implements Deno.ChildProcess {

return p;
}

/**
* The bytes from `stdout`.
*/
async collect() {
return await this.stdout.collect();
}

/**
* The `stdout` data as a string.
*/
async asString() {
return (await text(this.stdout).collect()).join();
}

/**
* Collect `stdout` as lines of text.
*/
async collectLines() {
return await lines(this.stdout).collect();
}
}

0 comments on commit b693d33

Please sign in to comment.