diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70124f5decf..73aea8cc0cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,4 +12,6 @@ jobs: - name: Install Dependencies run: yarn - name: Build - run: yarn build \ No newline at end of file + run: yarn build + - name: Check Links + run: yarn linkcheck diff --git a/_tools/linkcheck.ts b/_tools/linkcheck.ts new file mode 100755 index 00000000000..3dac5b5e2c9 --- /dev/null +++ b/_tools/linkcheck.ts @@ -0,0 +1,36 @@ +import { platform, exit } from 'process'; +import { spawn } from 'child_process'; + +const server = spawn('yarn', ['serve'], { + stdio: ['ignore', 'pipe', 'ignore'], +}); + +let output = ''; +server.stdout.on('data', (data) => { + console.log(data.toString()); + output = output + data.toString(); + if (output.indexOf('Serving files from') !== -1) { + let program; + if (platform === 'linux') { + program = 'linkcheck-linux'; + } else if (platform === 'darwin') { + program = 'linkcheck'; + } else { + program = 'linkcheck-win'; + } + const checker = spawn(program, [':4200'], { + stdio: ['ignore', 'pipe', 'ignore'], + }); + checker.stdout.on('data', (checkerData) => { + console.log(checkerData.toString()); + }); + checker.on('exit', (code, other) => { + console.log('linkcheck finished'); + server.stdout.destroy(); + server.kill(); + checker.stdout.destroy(); + checker.kill(); + exit(code); + }); + } +}); \ No newline at end of file diff --git a/package.json b/package.json index 389816f0ddf..2a8f1615ab3 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "serve": "NODE_ENV=development npx @11ty/eleventy --serve --port=4200", "build": "rm -rf _site && npx @11ty/eleventy", "deploy": "yarn build && firebase deploy", - "process": "yarn ts-node --skip-project _tools/process-data.ts" + "process": "yarn ts-node --skip-project _tools/process-data.ts", + "linkcheck": "yarn ts-node --skip-project _tools/linkcheck.ts" }, "keywords": [ "chainlink", @@ -21,6 +22,7 @@ "@readme/markdown": "^6.26.6", "@readme/variable": "^13.0.0", "@types/node": "^14.14.39", + "dart-linkcheck": "^2.0.15", "date-fns": "^2.21.1", "eleventy-plugin-youtube-embed": "^1.6.2", "firebase-tools": "^9.8.0", diff --git a/yarn.lock b/yarn.lock index 477039c4559..ae0aae450da 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1665,6 +1665,11 @@ d@1, d@^1.0.1: es5-ext "^0.10.50" type "^1.0.1" +dart-linkcheck@^2.0.15: + version "2.0.15" + resolved "https://registry.yarnpkg.com/dart-linkcheck/-/dart-linkcheck-2.0.15.tgz#cd581c804cdea94194557b48a0a654341097f762" + integrity sha512-ZMvxkAyEpBTvBFk+DPjcK0ObNy8GM4gmrGG1qIu0EXb/zj25vjRWNnhLHKZw4JlOLo02oWlwDeqo98GuBlJcIg== + dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"