From bab693791776d4a880d798a7f19d569d0105702b Mon Sep 17 00:00:00 2001 From: Marko Zabreznik Date: Fri, 10 Dec 2021 15:38:38 +0100 Subject: [PATCH 1/2] task: added stdin for passwords --- src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/index.ts b/src/index.ts index 24fecf6..10b63f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -176,6 +176,7 @@ export const dockerCommand = async ( echo: true, env: undefined, machineName: undefined, + stdin: undefined }, ) => { let machineconfig = ""; @@ -216,6 +217,10 @@ export const dockerCommand = async ( }, ); + if (options.stdin) { + childProcess.stdin.write(options.stdin); + } + if (options.echo) { childProcess.stdout.on("data", (chunk) => { process.stdout.write(chunk.toString()); @@ -240,6 +245,7 @@ export class Docker { echo: true, env: undefined, machineName: undefined, + stdin: undefined }, ) {} @@ -253,6 +259,7 @@ export interface IOptions { currentWorkingDirectory?: string; echo?: boolean; env?: NodeJS.ProcessEnv; + stdin?: string; } export class Options implements IOptions { @@ -261,5 +268,6 @@ export class Options implements IOptions { public currentWorkingDirectory?: string, public echo: boolean = true, public env?: NodeJS.ProcessEnv, + public stdin?: string, ) {} } From b3ba7776ac76fe3240b2d9d31feab442a3126882 Mon Sep 17 00:00:00 2001 From: Marko Zabreznik Date: Fri, 10 Dec 2021 15:39:58 +0100 Subject: [PATCH 2/2] fix: stdin needs to be ended --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index 10b63f6..38cf5ef 100644 --- a/src/index.ts +++ b/src/index.ts @@ -219,6 +219,7 @@ export const dockerCommand = async ( if (options.stdin) { childProcess.stdin.write(options.stdin); + childProcess.stdin.end(); } if (options.echo) {