Skip to content

Commit

Permalink
Fix removing old volumes if the service is not selected
Browse files Browse the repository at this point in the history
  • Loading branch information
arifszn committed Aug 6, 2023
1 parent 4ea7621 commit 25eeeda
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ const writeDockerComposeFileWithService = (
}
});

// Remove volumes if no services are selected
if (selectedServices.length === 0) {
const selectedServicesWithVolume = availableVolumes.filter((volume) =>
selectedServices.includes(volume),
);

if (selectedServicesWithVolume.length === 0) {
// Remove volumes if no services are selected
delete parsedCompose.volumes;
} else {
// Add selected volumes to the volumes section
availableVolumes.forEach((volume) => {
selectedServicesWithVolume.forEach((volume) => {
if (!(volume in parsedCompose.volumes)) {
parsedCompose.volumes[`vail-${volume}`] = { driver: 'local' };
}
Expand Down

0 comments on commit 25eeeda

Please sign in to comment.