trailing newline .ftl check can happen at build time

Removes the need to build ripgrep for CI
This commit is contained in:
Damien Elmes 2020-11-01 14:59:45 +10:00
parent b17d537a9e
commit 0cf964b16d
3 changed files with 4 additions and 21 deletions

View File

@ -1,19 +0,0 @@
#!/bin/bash
set -eu -o pipefail ${SHELLFLAGS}
# Checking version to force it fail the build if rg is not installed.
# Because `set -e` does not work inside the subshell $()
if ! rg --version > /dev/null 2>&1;
then
echo "Error: ripgrep is not installed!";
exit 1;
fi;
files=$(rg -l '[^\n]\z' -g '!*.{png,svg,scss,json,sql}' || true)
if [ "$files" != "" ]; then
echo "the following files are missing a newline on the last line:"
echo $files
exit 1
fi

View File

@ -88,6 +88,9 @@ fn get_ftl_data_from_provided_files(sources: String) -> FTLData {
let path = Path::new("..").join(path);
std::fs::read_to_string(path).unwrap()
});
if !entry.ends_with("\n") {
panic!(".ftl file should end with a newline: {}", path);
}
match (first_parent, second_parent) {
// templates in the rslib translation repo are ignored, as their canonical
// form is part of this source tree

View File

@ -79,8 +79,7 @@ macro_rules! ftl_path {
};
}
/// Get the template/English resource text for the given group.
/// These are embedded in the binary.
/// Get the template/English resource text.
fn ftl_template_text() -> &'static str {
ftl_path!("template.ftl")
}