tree-sitter/update: make the repo check into a boolean test
This commit is contained in:
parent
d2988dac8e
commit
0b1bfd7d14
1 changed files with 10 additions and 12 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
# Grammars we want to fetch from the tree-sitter github orga
|
# Grammars we want to fetch from the tree-sitter github orga
|
||||||
knownTreeSitterOrgGrammarRepos = [
|
knownTreeSitterOrgGrammarRepos = jsonFile "known-tree-sitter-org-grammar-repos" [
|
||||||
"tree-sitter-javascript"
|
"tree-sitter-javascript"
|
||||||
"tree-sitter-c"
|
"tree-sitter-c"
|
||||||
"tree-sitter-swift"
|
"tree-sitter-swift"
|
||||||
|
@ -36,7 +36,7 @@ let
|
||||||
];
|
];
|
||||||
|
|
||||||
# repos of the tree-sitter github orga we want to ignore (not grammars)
|
# repos of the tree-sitter github orga we want to ignore (not grammars)
|
||||||
ignoredTreeSitterOrgRepos = [
|
ignoredTreeSitterOrgRepos = jsonFile "ignored-tree-sitter-org-repos" [
|
||||||
"tree-sitter"
|
"tree-sitter"
|
||||||
"tree-sitter-cli"
|
"tree-sitter-cli"
|
||||||
# this is the haskell language bindings, tree-sitter-haskell is the grammar
|
# this is the haskell language bindings, tree-sitter-haskell is the grammar
|
||||||
|
@ -59,14 +59,12 @@ let
|
||||||
|
|
||||||
jsonFile = name: val: (formats.json {}).generate name val;
|
jsonFile = name: val: (formats.json {}).generate name val;
|
||||||
|
|
||||||
# check in the list of grammars, whether we know all of them.
|
# check the tree-sitter orga repos
|
||||||
checkKnownGrammars = writeShellScript "get-grammars.sh" ''
|
checkTreeSitterRepos = writeShellScript "get-grammars.sh" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
known="${jsonFile "known-tree-sitter-org-grammar-repos" knownTreeSitterOrgGrammarRepos}"
|
|
||||||
ignore="${jsonFile "ignored-tree-sitter-org-repos" ignoredTreeSitterOrgRepos}"
|
|
||||||
res=$(${jq}/bin/jq \
|
res=$(${jq}/bin/jq \
|
||||||
--slurpfile known "$known" \
|
--slurpfile known "${knownTreeSitterOrgGrammarRepos}" \
|
||||||
--slurpfile ignore "$ignore" \
|
--slurpfile ignore "${ignoredTreeSitterOrgRepos}" \
|
||||||
'. - ($known[0] + $ignore[0])' \
|
'. - ($known[0] + $ignore[0])' \
|
||||||
)
|
)
|
||||||
if [ ! "$res" == "[]" ]; then
|
if [ ! "$res" == "[]" ]; then
|
||||||
|
@ -74,7 +72,6 @@ let
|
||||||
echo "$res" 1>&2
|
echo "$res" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cat "$known"
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
@ -132,9 +129,10 @@ let
|
||||||
update-all-grammars = writeShellScript "update-all-grammars.sh" ''
|
update-all-grammars = writeShellScript "update-all-grammars.sh" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
echo "fetching list of grammars" 1>&2
|
echo "fetching list of grammars" 1>&2
|
||||||
grammars=$(${latestGithubRepos { orga = "tree-sitter"; }})
|
treeSitterRepos=$(${latestGithubRepos { orga = "tree-sitter"; }})
|
||||||
echo "checking against the list of grammars we know" 1>&2
|
echo "checking the tree-sitter repo list against the grammars we know" 1>&2
|
||||||
knownGrammars=$(printf '%s' "$grammars" | ${checkKnownGrammars})
|
printf '%s' "$treeSitterRepos" | ${checkTreeSitterRepos}
|
||||||
|
knownGrammars=$(cat "${knownTreeSitterOrgGrammarRepos}")
|
||||||
# change the json list into a item-per-line bash format
|
# change the json list into a item-per-line bash format
|
||||||
grammarNames=$(printf '%s' "$knownGrammars" | ${jq}/bin/jq --raw-output '.[]')
|
grammarNames=$(printf '%s' "$knownGrammars" | ${jq}/bin/jq --raw-output '.[]')
|
||||||
outputDir="${toString ./.}/grammars"
|
outputDir="${toString ./.}/grammars"
|
||||||
|
|
Loading…
Reference in a new issue