mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-13 19:51:52 +00:00
wip: poc docker compose
This commit is contained in:
parent
7eaf706be9
commit
9677f1ab45
1 changed files with 22 additions and 3 deletions
25
src/index.ts
25
src/index.ts
|
|
@ -122,7 +122,7 @@ const configToArgs = (config): string[] => {
|
|||
* Converts docker-compose commandline options to cli arguments
|
||||
*/
|
||||
const composeOptionsToArgs = (composeOptions): string[] => {
|
||||
let composeArgs: string[] = []
|
||||
let composeArgs: string[] = ['compose']
|
||||
|
||||
composeOptions.forEach((option: string[] | string): void => {
|
||||
if (option instanceof Array) {
|
||||
|
|
@ -136,6 +136,24 @@ const composeOptionsToArgs = (composeOptions): string[] => {
|
|||
return composeArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts docker-compose commandline options to cli arguments
|
||||
*/
|
||||
const commandOptionsToArgs = (commandOptions): string[] => {
|
||||
let commandArgs: string[] = []
|
||||
|
||||
commandOptions.forEach((option: string[] | string): void => {
|
||||
if (option instanceof Array) {
|
||||
commandArgs = commandArgs.concat(option)
|
||||
}
|
||||
if (typeof option === 'string') {
|
||||
commandArgs = commandArgs.concat([option])
|
||||
}
|
||||
})
|
||||
|
||||
return commandArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes docker-compose command with common options
|
||||
*/
|
||||
|
|
@ -156,13 +174,14 @@ export const execCompose = (
|
|||
|
||||
composeArgs = composeArgs.concat(
|
||||
configArgs.concat(
|
||||
[command].concat(composeOptionsToArgs(commandOptions), args)
|
||||
[command].concat(commandOptionsToArgs(commandOptions), args)
|
||||
)
|
||||
)
|
||||
|
||||
const cwd = options.cwd
|
||||
const env = options.env || undefined
|
||||
const executablePath = options.executablePath || 'docker-compose'
|
||||
const executablePath =
|
||||
'docker' || options.executablePath || 'docker-compose'
|
||||
|
||||
const childProc = childProcess.spawn(executablePath, composeArgs, {
|
||||
cwd,
|
||||
|
|
|
|||
Loading…
Reference in a new issue