diff --git a/src/index.ts b/src/index.ts index 04ddd69b..f2bb09df 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,12 +183,21 @@ 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 childProc = childProcess.spawn(executablePath, composeArgs, { - cwd, - env - }) + const executableOptions = executable.options || [] + const executableArgs = composeOptionsToArgs(executableOptions) + + 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 891268be..ad350bd1 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