(cliHost: FileHost, config: DevContainerFromDockerComposeConfig, envForComposeFile: NodeJS.ProcessEnv, cwdForDefaultFiles: string)
| 231 | } |
| 232 | |
| 233 | export async function getDockerComposeFilePaths(cliHost: FileHost, config: DevContainerFromDockerComposeConfig, envForComposeFile: NodeJS.ProcessEnv, cwdForDefaultFiles: string) { |
| 234 | if (Array.isArray(config.dockerComposeFile)) { |
| 235 | if (config.dockerComposeFile.length) { |
| 236 | return config.dockerComposeFile.map(composeFile => uriToFsPath(getConfigFilePath(cliHost, config, composeFile), cliHost.platform)); |
| 237 | } |
| 238 | } else if (typeof config.dockerComposeFile === 'string') { |
| 239 | return [uriToFsPath(getConfigFilePath(cliHost, config, config.dockerComposeFile), cliHost.platform)]; |
| 240 | } |
| 241 | |
| 242 | const envComposeFile = envForComposeFile?.COMPOSE_FILE; |
| 243 | if (envComposeFile) { |
| 244 | return envComposeFile.split(cliHost.path.delimiter) |
| 245 | .map(composeFile => cliHost.path.resolve(cwdForDefaultFiles, composeFile)); |
| 246 | } |
| 247 | |
| 248 | try { |
| 249 | const envPath = cliHost.path.join(cwdForDefaultFiles, '.env'); |
| 250 | const buffer = await cliHost.readFile(envPath); |
| 251 | const match = /^COMPOSE_FILE=(.+)$/m.exec(buffer.toString()); |
| 252 | const envFileComposeFile = match && match[1].trim(); |
| 253 | if (envFileComposeFile) { |
| 254 | return envFileComposeFile.split(cliHost.path.delimiter) |
| 255 | .map(composeFile => cliHost.path.resolve(cwdForDefaultFiles, composeFile)); |
| 256 | } |
| 257 | } catch (err) { |
| 258 | if (!(err && (err.code === 'ENOENT' || err.code === 'EISDIR'))) { |
| 259 | throw err; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | const defaultFiles = [cliHost.path.resolve(cwdForDefaultFiles, 'docker-compose.yml')]; |
| 264 | const override = cliHost.path.resolve(cwdForDefaultFiles, 'docker-compose.override.yml'); |
| 265 | if (await cliHost.isFile(override)) { |
| 266 | defaultFiles.push(override); |
| 267 | } |
| 268 | return defaultFiles; |
| 269 | } |
no test coverage detected