maybe this will fix it

This commit is contained in:
William Harrison committed 2025-01-02 19:53:15 +08:00
1 parent 2f31cd7748
commit ec4e7b5676
1 file changed
+5 -9
+5 -9
View File
@@ -3,11 +3,7 @@ const fs = require("fs-extra");
const path = require("path"); const path = require("path");
const PR_AUTHOR = process.env.PR_AUTHOR; const PR_AUTHOR = process.env.PR_AUTHOR;
let MODIFIED_FILES = process.env.MODIFIED_FILES.split(" "); const MODIFIED_FILES = process.env.MODIFIED_FILES.split(" ");
for (let i = 0; i < MODIFIED_FILES.length; i++) {
MODIFIED_FILES[i] = MODIFIED_FILES[i].substring(MODIFIED_FILES[i].lastIndexOf("/") + 1);
}
const domainsPath = path.resolve("domains"); const domainsPath = path.resolve("domains");
const headDomainsPath = path.resolve(`register-${process.env.RUN_ID}/domains`); const headDomainsPath = path.resolve(`register-${process.env.RUN_ID}/domains`);
@@ -21,11 +17,11 @@ t("Modified JSON files must be owned by the PR author", (t) => {
} }
MODIFIED_FILES.forEach((file) => { MODIFIED_FILES.forEach((file) => {
const modifiedDomain = fs.readJsonSync(path.join(domainsPath, file)); const modifiedDomain = fs.readJsonSync(path.join(domainsPath, file.substring(MODIFIED_FILES[i].lastIndexOf("/") + 1)));
let currentDomain = null; let currentDomain = null;
try { try {
currentDomain = fs.readJsonSync(path.join(headDomainsPath, file)); currentDomain = fs.readJsonSync(path.join(headDomainsPath, file.substring(MODIFIED_FILES[i].lastIndexOf("/") + 1)));
} catch { } catch {
currentDomain = modifiedDomain; currentDomain = modifiedDomain;
} }
@@ -44,10 +40,10 @@ t("New JSON files must be owned by the PR author", (t) => {
return; return;
} }
const newFiles = fs.readdirSync(domainsPath).filter((file) => !fs.readdirSync(headDomainsPath).includes(file)); const newFiles = fs.readdirSync(domainsPath).filter((file) => !fs.readdirSync(headDomainsPath).includes(file.substring(MODIFIED_FILES[i].lastIndexOf("/") + 1)));
newFiles.forEach((file) => { newFiles.forEach((file) => {
const domain = fs.readJsonSync(path.join(domainsPath, file)); const domain = fs.readJsonSync(path.join(domainsPath, file.substring(MODIFIED_FILES[i].lastIndexOf("/") + 1)));
t.true( t.true(
domain.owner.username === PR_AUTHOR || admins.includes(PR_AUTHOR), domain.owner.username === PR_AUTHOR || admins.includes(PR_AUTHOR),