mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-08-22 22:24:05 +00:00
test logging
This commit is contained in:
+5
-9
@@ -7,22 +7,18 @@ const MODIFIED_FILES = (process.env.MODIFIED_FILES || "").split(" ").map((file)
|
||||
const EVENT = process.env.EVENT;
|
||||
const RUN_ID = process.env.RUN_ID;
|
||||
|
||||
console.log(MODIFIED_FILES)
|
||||
|
||||
const domainsPath = path.resolve("domains");
|
||||
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 2;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +33,7 @@ t("Modified JSON files must be owned by the PR author", async (t) => {
|
||||
|
||||
const domainToCheck = currentDomain || modifiedDomain;
|
||||
|
||||
if (modifiedDomain === 2 || domainToCheck === 2) {
|
||||
if (!modifiedDomain || !domainToCheck) {
|
||||
t.fail(`${file}: Unable to read domain data`);
|
||||
return;
|
||||
}
|
||||
@@ -62,7 +58,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 === 2) return t.fail(`${file}: Unable to read domain data`);
|
||||
if (!domain) 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