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