Skip to content

Commit

Permalink
Add check-folder-structure
Browse files Browse the repository at this point in the history
  • Loading branch information
RadxaYuntian committed Dec 1, 2023
1 parent 2c1448f commit d75711e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@
entry: pre_commit_hooks/main.sh remove-category-json
language: script
types: [json]
- id: check-folder-structure
name: Ensure same folder structure between translations
entry: pre_commit_hooks/main.sh check-folder-structure
language: script
types_or: [file, symlink]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Please refer to `pre-commit` documentation about [developing hooks interactively
In short, run the following command in `radxa-doc/documentation` project folder:

```bash
pre-commit try-repo ../pre-commit-hooks --verbose --all-files
pre-commit try-repo ../pre-commit-hooks --verbose --all-files --hook-stage manual
pre-commit try-repo --verbose --all-files ../pre-commit-hooks
pre-commit try-repo --verbose --all-files --hook-stage manual ../pre-commit-hooks
pre-commit try-repo --verbose --all-files ../pre-commit-hooks check-folder-structure
```
18 changes: 18 additions & 0 deletions pre_commit_hooks/check-folder-structure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

check() {
local ret=0

# I18n folder structure should mirror each other
if [[ "$1" == docs/* ]] && [[ ! -e "i18n/en/docusaurus-plugin-content-docs/current/${1#docs/}" ]]
then
ret=1
echo "$1: missing English translation." >&2
elif [[ "$1" == i18n/en/docusaurus-plugin-content-docs/current/* ]] && [[ ! -e "docs/${1#i18n/en/docusaurus-plugin-content-docs/current/}" ]]
then
ret=1
echo "$1: missing Chinese translation." >&2
fi

return $ret
}

0 comments on commit d75711e

Please sign in to comment.