You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2021/09/07 14:24:00 UTC

[apisix-website] branch master updated: feat: add sync error handler (#561)

This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-website.git


The following commit(s) were added to refs/heads/master by this push:
     new f7614e8  feat: add sync error handler (#561)
f7614e8 is described below

commit f7614e8491ab815a5cc8c94222175a6369ddd65c
Author: bzp2010 <bz...@apache.org>
AuthorDate: Tue Sep 7 09:23:56 2021 -0500

    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 df8cc28..675c0e6 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 9e851d6..d1f3be5 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 0f57d5e..17284d0 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) => {