mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-16 02:15:46 +00:00
Merge branch 'main' into patch-11
This commit is contained in:
2 files changed
+5
-9
No files matched your search
@@ -41,7 +41,7 @@ jobs:
|
|||||||
repository: is-a-dev/register
|
repository: is-a-dev/register
|
||||||
path: register-${{ github.run_id }}
|
path: register-${{ github.run_id }}
|
||||||
|
|
||||||
- run: ls domain -1 | wc -l
|
- run: ls domains -1 | wc -l
|
||||||
- run: ls register-${{ github.run_id }}/domains -1 | wc -l
|
- run: ls register-${{ github.run_id }}/domains -1 | wc -l
|
||||||
|
|
||||||
- run: npm install
|
- run: npm install
|
||||||
|
|||||||
+4
-8
@@ -3,7 +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;
|
||||||
const MODIFIED_FILES = (process.env.MODIFIED_FILES || "").split(" ");
|
const MODIFIED_FILES = (process.env.MODIFIED_FILES || "").split(" ").map(file => file.replace(/^domains\//, ""));
|
||||||
const EVENT = process.env.EVENT;
|
const EVENT = process.env.EVENT;
|
||||||
const RUN_ID = process.env.RUN_ID;
|
const RUN_ID = process.env.RUN_ID;
|
||||||
|
|
||||||
@@ -23,13 +23,10 @@ async function getFileContent(basePath, fileName) {
|
|||||||
t("Modified JSON files must be owned by the PR author", async (t) => {
|
t("Modified JSON files must be owned by the PR author", async (t) => {
|
||||||
if (EVENT !== "pull_request") return t.pass();
|
if (EVENT !== "pull_request") return t.pass();
|
||||||
|
|
||||||
console.log("Modified files", MODIFIED_FILES);
|
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
MODIFIED_FILES.map(async (file) => {
|
MODIFIED_FILES.map(async (file) => {
|
||||||
const fileName = file.substring(file.lastIndexOf("/") + 1);
|
const modifiedDomain = await getFileContent(domainsPath, file);
|
||||||
const modifiedDomain = await getFileContent(domainsPath, fileName);
|
const currentDomain = (await getFileContent(headDomainsPath, file)) || modifiedDomain;
|
||||||
const currentDomain = (await getFileContent(headDomainsPath, fileName)) || modifiedDomain;
|
|
||||||
|
|
||||||
if (!modifiedDomain || !currentDomain) {
|
if (!modifiedDomain || !currentDomain) {
|
||||||
t.fail(`${file}: Unable to read domain data`);
|
t.fail(`${file}: Unable to read domain data`);
|
||||||
@@ -51,14 +48,13 @@ t("New JSON files must be owned by the PR author", async (t) => {
|
|||||||
|
|
||||||
const headDomainsFiles = fs.readdirSync(headDomainsPath);
|
const headDomainsFiles = fs.readdirSync(headDomainsPath);
|
||||||
|
|
||||||
// get list of all files that are in the base dir but not in the head dir
|
|
||||||
const newFiles = headDomainsFiles.filter((file) => !fs.existsSync(path.join(domainsPath, file)));
|
const newFiles = headDomainsFiles.filter((file) => !fs.existsSync(path.join(domainsPath, file)));
|
||||||
|
|
||||||
console.log("New files", newFiles);
|
console.log("New files", newFiles);
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
newFiles.map(async (file) => {
|
newFiles.map(async (file) => {
|
||||||
const domain = await getFileContent(domainsPath, file.substring(file.lastIndexOf("/") + 1));
|
const domain = await getFileContent(domainsPath, file);
|
||||||
|
|
||||||
if (!domain) {
|
if (!domain) {
|
||||||
t.fail(`${file}: Unable to read domain data`);
|
t.fail(`${file}: Unable to read domain data`);
|
||||||
|
|||||||
Reference in new issue
Block a user