From f7614e8491ab815a5cc8c94222175a6369ddd65c Mon Sep 17 00:00:00 2001 From: bzp2010 Date: Tue, 7 Sep 2021 09:23:56 -0500 Subject: [PATCH] feat: add sync error handler (#561) --- .github/workflows/link-check.yml | 1 + scripts/link-checker.js | 9 +++++---- scripts/sync-docs.js | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index df8cc28e0bb32..675c0e614ec84 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -31,6 +31,7 @@ jobs: - name: Install Dependencies run: | cd scripts && yarn install + cd ../website && yarn install - name: Pull Docs run: | diff --git a/scripts/link-checker.js b/scripts/link-checker.js index 9e851d663ccdb..d1f3be569b15b 100644 --- a/scripts/link-checker.js +++ b/scripts/link-checker.js @@ -1,6 +1,6 @@ const fs = require("fs"); const path = require("path"); -const childProcess = require("child_process"); +const process = require("process"); const listr = require("listr"); @@ -87,6 +87,7 @@ tasks.run() }) .catch(err => { console.error(err); + process.exit(1); }); const scanFolder = (tarDir) => { @@ -139,9 +140,9 @@ const scanLinkInMDFile = (filePath, project) => { } else if (url === "LICENSE" || url === 'logos/apache-apisix.png') { url = "https://github.com/apache/" + project + "/blob/master/" + url; } else if (!url.endsWith(".md")) { // not end with ".md" - console.log(filePath, link.url, filePath.startsWith("website\\docs")); - let lang = filePath.startsWith("website" + path.sep + "docs") ? "en" : filePath.split("i18n" + path.sep)[1].split(path.sep)[0]; - let subPath = filePath.startsWith("website" + path.sep + "docs") ? path.dirname(filePath.split("docs" + path.sep + project + path.sep)[1]) : path.dirname(filePath.split("docs-" + project + path.sep + "current" + path.sep)[1]); + console.log(filePath, link.url, url,filePath.startsWith("website\\docs")); + let lang = !filePath.includes("i18n") ? "en" : filePath.split("i18n" + path.sep)[1].split(path.sep)[0]; + let subPath = !filePath.includes("i18n") ? path.dirname(filePath.split("docs" + path.sep + project + path.sep)[1]) : path.dirname(filePath.split("docs-" + project + path.sep + "current" + path.sep)[1]); subPath = subPath !== "." ? subPath + path.sep : ""; let originPath = path.normalize("docs" + path.sep + lang + path.sep + "latest" + path.sep + subPath + url).replace(/\\/g, '/'); diff --git a/scripts/sync-docs.js b/scripts/sync-docs.js index 0f57d5e6d2d7e..17284d0302828 100644 --- a/scripts/sync-docs.js +++ b/scripts/sync-docs.js @@ -1,6 +1,7 @@ const childProcess = require("child_process"); const fs = require("fs"); const path = require("path"); +const process = require("process"); const listr = require("listr"); const simpleGit = require("simple-git"); const axios = require("axios"); @@ -272,6 +273,7 @@ tasks.run() }) .catch(err => { console.error(err); + process.exit(1); }); const log = (text) => {