Skip to content

Commit

Permalink
test: compile checker every time
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaquin Montes committed Aug 14, 2023
1 parent b3582bf commit a639601
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
18 changes: 11 additions & 7 deletions .github/actions/validate-docs-links/lib/index.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions .github/actions/validate-docs-links/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
"files": [
"src"
],
"type": "module",
"scripts": {
"test": "ts-node --files src/checker.ts",
"build": "yarn run types && ncc -m -o ./lib build src/index.ts --target es --license licenses.txt",
"local:build": "yarn run types && ncc -m -o ./dist build src/checker.ts && yarn local:check",
"local:check": "node lib/checker --run-local-checker",
"action:build": "yarn run types && ncc -m -o ./lib build src/index.ts --license licenses.txt",
"build": "yarn action:build",
"types": "tsc"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/validate-docs-links/src/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type FailureFunction = (message: string) => void
const RELATIVE_PATH = '/'
const EXCLUDED_HASHES = ['top']

const slugger = (require.main === module) ? {
const slugger = (process.argv[2] === '--run-local-checker') ? {
slug: (str: string) => str.replace(/\s+/g, '-').toLowerCase(),
reset: () => null
} : new GithubSlugger()
Expand Down Expand Up @@ -240,7 +240,7 @@ const formatTableRow = (
docPath: string,
sha?: string
) => {
if (require.main === module) return `| ${link} | ${errorType} | /${docPath} | \n`
if (process.argv[2] === '--run-local-checker') return `| ${link} | ${errorType} | /${docPath} | \n`
return `| ${link} | ${errorType} | [/${docPath}](https://github.com/meilisearch/documentation/blob/${sha}/${docPath}) | \n`
}

Expand Down Expand Up @@ -322,6 +322,6 @@ export async function validateAllInternalLinks(basePath: string, setFailed: Fail
}
}

if (require.main === module) {
if (process.argv[2] === '--run-local-checker') {
validateAllInternalLinks('../../../', (message) => {throw new Error(message)})
}
7 changes: 0 additions & 7 deletions .github/actions/validate-docs-links/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@
"noImplicitAny": true,
"allowSyntheticDefaultImports": true,
},
"ts-node": {
// "esModuleInterop": true,
// "esm": true,
// "compilerOptions": {
// "module": "CommonJS",
// }
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,7 @@ yarn-error.log

.vuepress/code-samples/generated-samples.json

### Links checker
.github/actions/validate-docs-links/dist

# End of https://www.gitignore.io/api/vue,node,vuejs

0 comments on commit a639601

Please sign in to comment.