mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-08-21 00:24:54 +00:00
Update pr.test.js
This commit is contained in:
+9
-3
@@ -13,10 +13,16 @@ const headDomainsPath = path.resolve(`register-${RUN_ID}/domains`);
|
||||
const admins = require("../util/administrators.json").map(admin => admin.toLowerCase());
|
||||
|
||||
async function getJSONContent(basePath, fileName) {
|
||||
const jsonPath = path.join(basePath, fileName)
|
||||
|
||||
if (!fs.existsSync(jsonPath)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
return await fs.readJson(path.join(basePath, fileName));
|
||||
} catch {
|
||||
return null;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +37,7 @@ t("Modified JSON files must be owned by the PR author", async (t) => {
|
||||
|
||||
const domainToCheck = currentDomain || modifiedDomain;
|
||||
|
||||
if (!modifiedDomain || !domainToCheck) {
|
||||
if (modifiedDomain === 2 || domainToCheck === 2) {
|
||||
t.fail(`${file}: Unable to read domain data`);
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +62,7 @@ t("New JSON files must be owned by the PR author", async (t) => {
|
||||
const checks = newDomainFiles.map(async (file) => {
|
||||
const domain = await getJSONContent(domainsPath, file);
|
||||
|
||||
if (!domain) return t.fail(`${file}: Unable to read domain data`);
|
||||
if (!domain === 2) return t.fail(`${file}: Unable to read domain data`);
|
||||
|
||||
t.true(
|
||||
domain.owner.username.toLowerCase() === PR_AUTHOR || admins.includes(PR_AUTHOR),
|
||||
|
||||
Reference in New Issue
Block a user