fix: refs #5123 clean now merges directories when archive exists

This commit is contained in:
Juan Ferrer 2024-01-17 17:53:48 +01:00
parent 85af498e15
commit 7208a8284f
3 changed files with 21 additions and 8 deletions

View File

@ -52,11 +52,24 @@ class Clean extends Command {
if (!await fs.pathExists(archiveDir))
await fs.mkdir(archiveDir);
for (const oldVersion of oldVersions)
for (const oldVersion of oldVersions) {
const srcDir = path.join(opts.versionsDir, oldVersion);
const dstDir = path.join(archiveDir, oldVersion);
if (!await fs.pathExists(dstDir))
await fs.mkdir(dstDir);
const scripts = await fs.readdir(srcDir);
for (const script of scripts) {
await fs.move(
path.join(opts.versionsDir, oldVersion),
path.join(archiveDir, oldVersion)
path.join(srcDir, script),
path.join(dstDir, script),
{overwrite: true}
);
}
await fs.rmdir(srcDir);
}
console.log(`Old versions archived: ${oldVersions.length}`);
} else

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@verdnatura/myt",
"version": "1.5.25",
"version": "1.5.26",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@verdnatura/myt",
"version": "1.5.25",
"version": "1.5.26",
"license": "GPL-3.0",
"dependencies": {
"@sqltools/formatter": "^1.2.5",

View File

@ -1,6 +1,6 @@
{
"name": "@verdnatura/myt",
"version": "1.5.25",
"version": "1.5.26",
"author": "Verdnatura Levante SL",
"description": "MySQL version control",
"license": "GPL-3.0",