-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dependencies; removed new API as it is at a dead end
- Loading branch information
Showing
21 changed files
with
169 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
HERE="$(realpath "$(dirname "$0")")" | ||
|
||
deno install -rf --allow-read="$HERE/" --allow-write="$HERE/" --allow-net https://deno.land/x/udd/main.ts | ||
|
||
cd "$HERE/legacy/" && ( | ||
./build.ts | ||
) | ||
|
||
cd "$HERE/" && ( | ||
./build.sh | ||
) |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from "https://deno.land/std@0.177.1/testing/asserts.ts"; | ||
export * from "https://deno.land/std@0.190.0/testing/asserts.ts"; | ||
export * from "https://deno.land/x/[email protected]/mod.ts"; | ||
export * from "https://deno.land/std@0.177.1/fmt/colors.ts"; | ||
export * from "https://deno.land/std@0.190.0/fmt/colors.ts"; |
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,2 +1,2 @@ | ||
export * from "https://deno.land/std@0.177.1/async/mod.ts"; | ||
export * from "https://deno.land/std@0.177.1/io/mod.ts"; | ||
export * from "https://deno.land/std@0.190.0/async/mod.ts"; | ||
export * from "https://deno.land/std@0.190.0/io/mod.ts"; |
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 |
---|---|---|
|
@@ -2,8 +2,9 @@ | |
|
||
import { Answer, Question } from "./common-json-defs.ts"; | ||
import * as proc from "../../mod.ts"; | ||
import { PushIterable } from "../../../mod1.ts"; | ||
import { asynciter } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { blue, red } from "https://deno.land/std@0.177.1/fmt/colors.ts"; | ||
import { blue, red } from "https://deno.land/std@0.190.0/fmt/colors.ts"; | ||
|
||
/** | ||
* This demonstrates sending objects to and receiving objects from a child process | ||
|
@@ -12,7 +13,7 @@ import { blue, red } from "https://deno.land/[email protected]/fmt/colors.ts"; | |
* This shows how you can use `proc` to implement a worker using child processes. | ||
*/ | ||
|
||
const it = new proc.PushIterable<Question>(); | ||
const it = new PushIterable<Question>(); | ||
|
||
/* | ||
* Write "questions" to the push-iterable. | ||
|
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
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
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,2 +1,2 @@ | ||
export * from "./src/proc-readable-stream.ts"; | ||
export * from "./legacy/mod.ts"; | ||
/* Stable (legacy) API only for now. */ | ||
export * from "./mod1.ts"; |
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 @@ | ||
export * from "./legacy/mod.ts"; |
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,2 @@ | ||
export * from "./src/proc-readable-stream.ts"; | ||
export * from "./src/push-iterable.ts"; |
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,122 @@ | ||
// deno-lint-ignore-file no-inner-declarations | ||
import { readableStreamFromIterable } from "./deps/streams.ts"; | ||
import { PushIterable } from "./push-iterable.ts"; | ||
|
||
export type PipeKinds = "piped" | "inherit" | "null"; | ||
|
||
export async function pipeTo<T>(src: AsyncIterable<T>, dest: PushIterable<T>) { | ||
try { | ||
for await (const item of src) { | ||
dest.write(item); | ||
} | ||
} finally { | ||
dest.close(); | ||
} | ||
} | ||
|
||
export async function* pipeThrough<T, U>( | ||
src: AsyncIterable<T>, | ||
transform: (item: T) => U | Promise<U>, | ||
): AsyncIterableIterator<U> { | ||
for await (const item of src) { | ||
yield transform(item); | ||
} | ||
} | ||
|
||
export class Shell implements Deno.Closer { | ||
constructor() {} | ||
|
||
async close(): Promise<void> { | ||
} | ||
} | ||
|
||
/** Command options. */ | ||
export interface ProcIterOptions { | ||
/** Current working directory. */ | ||
readonly cwd?: string; | ||
/** Environment variables. */ | ||
readonly env?: Record<string, string>; | ||
|
||
stdin: PipeKinds; | ||
stdout: PipeKinds; | ||
stderr: PipeKinds; | ||
} | ||
|
||
export class ProcIterProcess implements Deno.Closer { | ||
constructor( | ||
public shell: Shell, | ||
protected readonly process: Deno.ChildProcess, | ||
) {} | ||
|
||
private _stderr: AsyncIterableIterator<Uint8Array> | undefined; | ||
private _stdout: AsyncIterableIterator<Uint8Array> | undefined; | ||
private _stdin: PushIterable<Uint8Array> | undefined; | ||
|
||
async close(): Promise<void> { | ||
if (this._stdin != null) { | ||
await this.stdin.close(); | ||
} | ||
} | ||
|
||
get pid() { | ||
return this.process.pid; | ||
} | ||
|
||
async status() { | ||
return await this.process.status; | ||
} | ||
|
||
get stderr(): AsyncIterableIterator<Uint8Array> { | ||
if (this._stderr == null) { | ||
const process = this.process; | ||
async function* gen() { | ||
yield* process.stderr; | ||
} | ||
this._stderr = gen(); | ||
} | ||
return this._stderr; | ||
} | ||
|
||
get stdout(): AsyncIterableIterator<Uint8Array> { | ||
if (this._stdout == null) { | ||
const process = this.process; | ||
async function* gen() { | ||
yield* process.stdout; | ||
} | ||
this._stdout = gen(); | ||
} | ||
return this._stdout; | ||
} | ||
|
||
get stdin(): PushIterable<Uint8Array> { | ||
if (this._stdin == null) { | ||
const pi = new PushIterable<Uint8Array>({ | ||
onclose: () => this.stdin.close(), | ||
}); | ||
readableStreamFromIterable(pi).pipeTo(this.process.stdin); | ||
this._stdin = pi; | ||
} | ||
return this._stdin; | ||
} | ||
} | ||
|
||
export class ProcIter { | ||
readonly args: readonly string[]; | ||
|
||
constructor( | ||
public shell: Shell, | ||
public readonly options: ProcIterOptions, | ||
public readonly cmd: string | URL, | ||
...args: string[] | ||
) { | ||
this.args = [...args]; | ||
} | ||
|
||
spawn() { | ||
return new ProcIterProcess( | ||
this.shell, | ||
new Deno.Command(this.cmd, { ...this.options, args: [...this.args] }) | ||
.spawn(), | ||
); | ||
} | ||
} |
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
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