From 2c4e9e8597948ea402f087d100b1fcb96b5466be Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Wed, 24 Mar 2021 21:03:15 +0100 Subject: [PATCH] add .write method --- README.md | 4 +++- src/index.ts | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f24841..31b5714 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # An async wrapper for nodejs' `spawn` ```typescript -import { simpleSpawn } from "async-spawner"; +import simpleSpawn from "async-spawner"; await simpleSpawn("ls", ["-al"]); ``` @@ -12,6 +12,8 @@ let response; do{ response = await ping.waitForNextData(); console.log("new ping!", response); + + // you can also write to stdin with ping.write("some string") } ping.kill(); ``` diff --git a/src/index.ts b/src/index.ts index 1c2dac7..6f9c0be 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,6 +42,10 @@ class DeferedSpawn extends Emittery { debugger; console.log("killed map!"); } + + write(data: string) { + this.process.stdin.write(data); + } } export function deferedSpawn(