From 89cfa6508409cc87b1d88420b496e1c85693a52b Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 25 Jan 2024 19:28:51 +0100 Subject: [PATCH] fix: refs #5483 routines path now uses subdir --- myt-pull.js | 2 +- myt-push.js | 3 ++- myt.js | 16 ++++++++++++---- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/myt-pull.js b/myt-pull.js index 60bef3e..a106bbf 100755 --- a/myt-pull.js +++ b/myt-pull.js @@ -50,7 +50,7 @@ class Pull extends Command { const match = patch .newFile() .path() - .match(/^routines\/(.+)\.sql$/); + .match(opts.routinesRegex); if (match) return true; } diff --git a/myt-push.js b/myt-push.js index fca5b9a..e40fa2c 100644 --- a/myt-push.js +++ b/myt-push.js @@ -461,13 +461,14 @@ class Push extends Command { const changes = []; const changesMap = new Map(); + const {opts} = this; async function pushChanges(diff) { if (!diff) return; const patches = await diff.patches(); for (const patch of patches) { const path = patch.newFile().path(); - const match = path.match(/^routines\/(.+)\.sql$/); + const match = path.match(opts.routinesRegex); if (!match) continue; let change = changesMap.get(match[1]); diff --git a/myt.js b/myt.js index e84c941..128c3b8 100755 --- a/myt.js +++ b/myt.js @@ -205,12 +205,20 @@ class Myt { Object.assign(opts, config); opts.configFile = configFile; + const subdir = opts.subdir || ''; if (!opts.mytDir) - opts.mytDir = path.join(opts.workspace, opts.subdir || ''); + opts.mytDir = path.join(opts.workspace, subdir); - opts.routinesDir = path.join(opts.mytDir, 'routines'); - opts.versionsDir = path.join(opts.mytDir, 'versions'); - opts.dumpDir = path.join(opts.mytDir, 'dump'); + const routinesBaseRegex = subdir + ? `${subdir}\/routines` + : 'routines'; + + Object.assign(opts, { + routinesRegex: new RegExp(`^${routinesBaseRegex}\/(.+)\.sql$`), + routinesDir: path.join(opts.mytDir, 'routines'), + versionsDir: path.join(opts.mytDir, 'versions'), + dumpDir: path.join(opts.mytDir, 'dump') + }); // Database configuration diff --git a/package-lock.json b/package-lock.json index 015f97e..34ba54a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@verdnatura/myt", - "version": "1.5.30", + "version": "1.5.31", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@verdnatura/myt", - "version": "1.5.30", + "version": "1.5.31", "license": "GPL-3.0", "dependencies": { "@sqltools/formatter": "^1.2.5", diff --git a/package.json b/package.json index 5387c6a..c29db8a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@verdnatura/myt", - "version": "1.5.30", + "version": "1.5.31", "author": "Verdnatura Levante SL", "description": "MySQL version control", "license": "GPL-3.0",