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",