forked from ministryofjustice/tax-tribunals-datacapture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (40 loc) · 1.41 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
SOURCE_YAML_FILES := config/locales/*.yml
COMBINED_YAML_FILE := config/locales/en.yml
# Combine all the yaml files into a single
# file, and delete all the others
merge_yaml_files:
rm $(COMBINED_YAML_FILE) || true
make clean_yaml_files
./bin/merge_yaml $(SOURCE_YAML_FILES) > $(COMBINED_YAML_FILE)
ls -1 $(SOURCE_YAML_FILES) | grep -v $(COMBINED_YAML_FILE) | xargs rm
find_duplicate_strings:
# WARNING: There is a tab inside the [] of the sed command
cat $(COMBINED_YAML_FILE) | sed 's/^[ ]*//' | sort | uniq -c | sort -n
clean_yaml_files:
make remove_blank_lines
make remove_trailing_whitespace
make append_blank_line
# Blank lines after the *key* in a yaml file causes any html to be
# compacted onto a single line during the merge step. So, we remove
# any blank lines before doing that.
remove_blank_lines:
for f in $(SOURCE_YAML_FILES); do \
grep -v '^$$' $$f > foo; \
mv foo $$f; \
done
# Trailing whitespace causes html to be stringified, too,
# so we need to remove that as well
# WARNING: There is a tab inside the [] of the sed command
remove_trailing_whitespace:
for f in $(SOURCE_YAML_FILES); do \
cat $$f | sed 's/[ ]*$$//' > foo; \
mv foo $$f; \
done
# Yaml files that don't end with a blank line don't merge
# as cleanly (html is stringified, so we need to ensure every yaml
# file ends in a blank line
append_blank_line:
for f in $(SOURCE_YAML_FILES); do \
echo >> $$f; \
done
.PHONY: merge_yaml