Skip to content

Commit

Permalink
Merge pull request #30 from arifszn/old-volume
Browse files Browse the repository at this point in the history
Fix removing old volumes if the service is not selected
  • Loading branch information
arifszn authored Aug 6, 2023
2 parents 4ea7621 + 25eeeda commit 175f274
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 175f274

Please sign in to comment.