fix: refs #5123 clean now merges directories when archive exists
This commit is contained in:
parent
85af498e15
commit
7208a8284f
19
myt-clean.js
19
myt-clean.js
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue