Skip to content

Commit

Permalink
Merge pull request #261 from PooruTorie/master
Browse files Browse the repository at this point in the history
feat: pass executable
  • Loading branch information
AlexZeitler authored Feb 19, 2024
2 parents 3aaa16d + fe2dc3d commit 74c7c7b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
26 changes: 20 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions src/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 74c7c7b

Please sign in to comment.