Skip to content

Commit

Permalink
feat: add sync error handler (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 authored Sep 7, 2021
1 parent 7e051b2 commit f7614e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/link-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- name: Install Dependencies
run: |
cd scripts && yarn install
cd ../website && yarn install
- name: Pull Docs
run: |
Expand Down
9 changes: 5 additions & 4 deletions scripts/link-checker.js
Original file line number Diff line number Diff line change
@@ -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");

Expand Down Expand Up @@ -87,6 +87,7 @@ tasks.run()
})
.catch(err => {
console.error(err);
process.exit(1);
});

const scanFolder = (tarDir) => {
Expand Down Expand Up @@ -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, '/');

Expand Down
2 changes: 2 additions & 0 deletions scripts/sync-docs.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -272,6 +273,7 @@ tasks.run()
})
.catch(err => {
console.error(err);
process.exit(1);
});

const log = (text) => {
Expand Down

0 comments on commit f7614e8

Please sign in to comment.