From a407abdbab5ef7c7e47bb45a2e07acb6cc125501 Mon Sep 17 00:00:00 2001 From: Paul Triebel <52011439+PooruTorie@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:21:28 +0100 Subject: [PATCH 1/3] Update v2.ts Add Executable Options to DockerComposeOptions --- src/v2.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/v2.ts b/src/v2.ts index 891268be..5d4245cd 100644 --- a/src/v2.ts +++ b/src/v2.ts @@ -2,9 +2,14 @@ import childProcess from 'child_process' import yaml from 'yaml' import mapPorts from './v2-map-ports' +export interface IDockerComposeExecutableOptions { + executablePath: string, + options?: string[] | (string | string[])[] +} + export interface IDockerComposeOptions { cwd?: string - executablePath?: string + executable?: IDockerComposeExecutableOptions config?: string | string[] configAsString?: string log?: boolean @@ -205,11 +210,14 @@ export const execCompose = ( const cwd = options.cwd const env = options.env || undefined - const executablePath = options.executablePath || 'docker' + const executable = options.executable || {executablePath: "docker"} + + const executableOptions executable.options || [] + const executableArgs = composeOptionsToArgs(executableOptions) const childProc = childProcess.spawn( - executablePath, - ['compose', ...composeArgs], + executable.executablePath, + [...executableArgs, 'compose', ...composeArgs], { cwd, env From dbb964207d8964b694c4006778b793320d258850 Mon Sep 17 00:00:00 2001 From: Paul Triebel <52011439+PooruTorie@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:26:00 +0100 Subject: [PATCH 2/3] Update index.ts Add Executable Options to DockerComposeOptions for v1 --- src/index.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 04ddd69b..87429d3c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,9 +2,14 @@ import childProcess from 'child_process' import yaml from 'yaml' import mapPorts from './map-ports' +export interface IDockerComposeExecutableOptions { + executablePath: string, + options?: string[] | (string | string[])[] +} + export interface IDockerComposeOptions { cwd?: string - executablePath?: string + executable?: IDockerComposeExecutableOptions config?: string | string[] configAsString?: string log?: boolean @@ -178,9 +183,12 @@ export const execCompose = ( const cwd = options.cwd const env = options.env || undefined - const executablePath = options.executablePath || 'docker-compose' + const executable = options.executable || {executablePath: 'docker-compose'} + + const executableOptions executable.options || [] + const executableArgs = composeOptionsToArgs(executableOptions) - const childProc = childProcess.spawn(executablePath, composeArgs, { + const childProc = childProcess.spawn(executable.executablePath, executableArgs.concat(composeArgs), { cwd, env }) From fe2dc3dd6ffc860ec6daacc5a537bbf706442d22 Mon Sep 17 00:00:00 2001 From: Paul Triebel Date: Mon, 19 Feb 2024 17:59:52 +0100 Subject: [PATCH 3/3] Fix typo --- src/index.ts | 20 +++++++++++++------- src/v2.ts | 6 +++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 87429d3c..f2bb09df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import yaml from 'yaml' import mapPorts from './map-ports' export interface IDockerComposeExecutableOptions { - executablePath: string, + executablePath: string options?: string[] | (string | string[])[] } @@ -183,15 +183,21 @@ export const execCompose = ( const cwd = options.cwd const env = options.env || undefined - const executable = options.executable || {executablePath: 'docker-compose'} + const executable = options.executable || { + executablePath: 'docker-compose' + } - const executableOptions executable.options || [] + const executableOptions = executable.options || [] const executableArgs = composeOptionsToArgs(executableOptions) - const childProc = childProcess.spawn(executable.executablePath, executableArgs.concat(composeArgs), { - cwd, - env - }) + const childProc = childProcess.spawn( + executable.executablePath, + executableArgs.concat(composeArgs), + { + cwd, + env + } + ) childProc.on('error', (err): void => { reject(err) diff --git a/src/v2.ts b/src/v2.ts index 5d4245cd..ad350bd1 100644 --- a/src/v2.ts +++ b/src/v2.ts @@ -3,7 +3,7 @@ import yaml from 'yaml' import mapPorts from './v2-map-ports' export interface IDockerComposeExecutableOptions { - executablePath: string, + executablePath: string options?: string[] | (string | string[])[] } @@ -210,9 +210,9 @@ export const execCompose = ( const cwd = options.cwd const env = options.env || undefined - const executable = options.executable || {executablePath: "docker"} + const executable = options.executable || { executablePath: 'docker' } - const executableOptions executable.options || [] + const executableOptions = executable.options || [] const executableArgs = composeOptionsToArgs(executableOptions) const childProc = childProcess.spawn(