fixes #6204 regexp makes match
This commit is contained in:
parent
38aec90073
commit
5ccb3de3cb
23
myt-push.js
23
myt-push.js
|
@ -174,6 +174,10 @@ class Push extends Command {
|
||||||
|
|
||||||
if (await fs.pathExists(versionsDir)) {
|
if (await fs.pathExists(versionsDir)) {
|
||||||
const versionDirs = await fs.readdir(versionsDir);
|
const versionDirs = await fs.readdir(versionsDir);
|
||||||
|
const [[realm]] = await this.conn.query(
|
||||||
|
`SELECT realm
|
||||||
|
FROM versionConfig`
|
||||||
|
);
|
||||||
|
|
||||||
for (const versionDir of versionDirs) {
|
for (const versionDir of versionDirs) {
|
||||||
if (skipFiles.has(versionDir)) continue;
|
if (skipFiles.has(versionDir)) continue;
|
||||||
|
@ -207,8 +211,6 @@ class Push extends Command {
|
||||||
[opts.code, versionNumber]
|
[opts.code, versionNumber]
|
||||||
);
|
);
|
||||||
|
|
||||||
const realm = await myt.fetchDbRealm();
|
|
||||||
|
|
||||||
for (const script of scripts)
|
for (const script of scripts)
|
||||||
if (!isUndoScript(script)
|
if (!isUndoScript(script)
|
||||||
&& versionLog.findIndex(x => x.file == script) === -1) {
|
&& versionLog.findIndex(x => x.file == script) === -1) {
|
||||||
|
@ -220,16 +222,27 @@ class Push extends Command {
|
||||||
logVersion(`[${versionNumber}]`.cyan, versionName);
|
logVersion(`[${versionNumber}]`.cyan, versionName);
|
||||||
|
|
||||||
for (const script of scripts) {
|
for (const script of scripts) {
|
||||||
if (!/^[0-9]{2}-[a-zA-Z0-9_]+(\..+)?\.sql$/.test(script)) {
|
const match = script.match(/^[0-9]{2}-[a-zA-Z0-9_]+(?:\.(?!undo)([a-zA-Z0-9_]+))?(?:\.undo)?\.sql$/);
|
||||||
|
|
||||||
|
if (!match) {
|
||||||
logScript('[W]'.yellow, script, `Wrong file name.`);
|
logScript('[W]'.yellow, script, `Wrong file name.`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const skipRealm = match & match[1] && match[1] !== realm;
|
||||||
|
|
||||||
if (isUndoScript(script))
|
if (isUndoScript(script))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (isOtherRealmScript(script, realm))
|
if (match[1]) {
|
||||||
continue;
|
if (skipRealm) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!realm) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
const [[row]] = await conn.query(
|
const [[row]] = await conn.query(
|
||||||
`SELECT errorNumber FROM versionLog
|
`SELECT errorNumber FROM versionLog
|
||||||
WHERE code = ?
|
WHERE code = ?
|
||||||
|
|
8
myt.js
8
myt.js
|
@ -323,14 +323,6 @@ class Myt {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fetchDbRealm() {
|
|
||||||
const [[realm]] = await this.conn.query(
|
|
||||||
`SELECT realm
|
|
||||||
FROM versionConfig`
|
|
||||||
);
|
|
||||||
return realm?.realm;
|
|
||||||
}
|
|
||||||
parseVersionDir(versionDir) {
|
parseVersionDir(versionDir) {
|
||||||
const match = versionDir.match(/^([0-9]+)-([a-zA-Z0-9]+)?$/);
|
const match = versionDir.match(/^([0-9]+)-([a-zA-Z0-9]+)?$/);
|
||||||
if (!match) return null;
|
if (!match) return null;
|
||||||
|
|
Loading…
Reference in New Issue