Skip to content

Commit

Permalink
docker-compose: Handle existence of selectedComposeFileURIs and docke…
Browse files Browse the repository at this point in the history
…rComposeFileURI correctly (#326)

* docker-compose: Handle existence of selectedComposeFileURIs
and dockerComposeFileURI correctly
Fixes #302.

* Remove redundant check

* docker-compose: Handle command palette execution.
  • Loading branch information
PrashanthCorp authored Jul 25, 2018
1 parent 0622099 commit e5b2c84
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions commands/docker-compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,25 @@ async function compose(commands: ('up' | 'down')[], message: string, dockerCompo
return;
}

let selectedItems: Item[] = [];

if (dockerComposeFileUri) {
// tslint:disable-next-line:prefer-for-of // Grandfathered in
for (let i: number = 0; i < selectedComposeFileUris.length; i++) {
selectedItems.push(createItem(folder, selectedComposeFileUris[i]));
}
let commandParameterFileUris: vscode.Uri[];
if (selectedComposeFileUris && selectedComposeFileUris.length) {
commandParameterFileUris = selectedComposeFileUris;
} else if (dockerComposeFileUri) {
commandParameterFileUris = [dockerComposeFileUri];
} else {
commandParameterFileUris = [];
}
let selectedItems: Item[] = commandParameterFileUris.map(uri => createItem(folder, uri));
if (!selectedItems.length) {
// prompt for compose file
const uris: vscode.Uri[] = await getDockerComposeFileUris(folder);
if (!uris || uris.length === 0) {
vscode.window.showInformationMessage('Couldn\'t find any docker-compose files in your workspace.');
return;
}

const items: vscode.QuickPickItem[] = computeItems(folder, uris);
selectedItems.push(<Item>await ext.ui.showQuickPick(items, { placeHolder: `Choose Docker Compose file ${message}` }));
selectedItems = [<Item>await ext.ui.showQuickPick(items, { placeHolder: `Choose Docker Compose file ${message}` })];
}

const terminal: vscode.Terminal = createTerminal('Docker Compose');
Expand Down

0 comments on commit e5b2c84

Please sign in to comment.