MCPcopy Index your code
hub / github.com/devcontainers/cli / getDockerComposeFilePaths

Function getDockerComposeFilePaths

src/spec-configuration/configuration.ts:233–269  ·  view source on GitHub ↗
(cliHost: FileHost, config: DevContainerFromDockerComposeConfig, envForComposeFile: NodeJS.ProcessEnv, cwdForDefaultFiles: string)

Source from the content-addressed store, hash-verified

231}
232
233export 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}

Callers 3

doBuildFunction · 0.90
getImageBuildInfoFunction · 0.90

Calls 5

uriToFsPathFunction · 0.90
getConfigFilePathFunction · 0.85
readFileMethod · 0.65
execMethod · 0.65
isFileMethod · 0.65

Tested by

no test coverage detected