-
Notifications
You must be signed in to change notification settings - Fork 2
/
port
executable file
·40 lines (30 loc) · 967 Bytes
/
port
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
#!/usr/bin/env bash
set -euo pipefail
srcdir=client
targetdir=client2/src
esy build
files=$(find ${srcdir} -name "*.elm" | grep -v elm-stuff | sort)
ignore="IntDict.elm|StrDict.elm|DontPort.elm|Window/Events.elm|DarkKeyboard.elm|tests|JSONUtils.elm|StrSet.elm|IntSet.elm"
finished="x"
# "Types.elm|Defaults.elm|Util.elm"
files=$(echo "$files" | egrep -v "$finished" | egrep -v "$ignore")
for src in $files; do
# Snakecase it
name=$(basename -- "$src")
name=${name%".elm"} # remove .elm suffix
# Get the dir
dir=$(dirname "$src")
if [ "$dir" = "$srcdir" ]; then
dir="";
else
dir="${dir#"${srcdir}/"}"
dir="${dir}/"
fi
target="${targetdir}/${dir}${name}.ml"
echo "${src} -> ${target}";
newdir=$(dirname "${target}")
mkdir -p "${newdir}"
~/.local/bin/elm-format --json --elm-version 0.18 --stdin < "${src}" \
| _esy/default/build/default/src/translate.exe > "${target}" \
&& ocamlformat --inplace "${target}"
done