Skip to content

Commit

Permalink
use whole dir as project base name
Browse files Browse the repository at this point in the history
  • Loading branch information
NerdToMars committed Oct 21, 2023
1 parent 71180e7 commit 58aeac1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/spec-node/dockerCompose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ export async function findComposeContainer(params: DockerCLIParameters | DockerR
return list && list[0];
}

function pathToConcatenated(p: string): string {
return p.split(path.sep).join('');
}

export async function getProjectName(params: DockerCLIParameters | DockerResolverParameters, workspace: Workspace, composeFiles: string[]) {
const { cliHost } = 'cliHost' in params ? params : params.common;
const newProjectName = await useNewProjectName(params);
Expand All @@ -639,10 +643,11 @@ export async function getProjectName(params: DockerCLIParameters | DockerResolve
}
const configDir = workspace.configFolderPath;
const workingDir = composeFiles[0] ? cliHost.path.dirname(composeFiles[0]) : cliHost.cwd; // From https://github.com/docker/compose/blob/79557e3d3ab67c3697641d9af91866d7e400cfeb/compose/config/config.py#L290

if (equalPaths(cliHost.platform, workingDir, cliHost.path.join(configDir, '.devcontainer'))) {
return toProjectName(`${cliHost.path.basename(configDir)}_devcontainer`, newProjectName);
return toProjectName(`${pathToConcatenated(configDir)}_devcontainer`, newProjectName);
}
return toProjectName(cliHost.path.basename(workingDir), newProjectName);
return toProjectName(pathToConcatenated(workingDir), newProjectName);
}

function toProjectName(basename: string, newProjectName: boolean) {
Expand Down

0 comments on commit 58aeac1

Please sign in to comment.