chiark / gitweb /
changelog: document further make-release changes
[otter.git] / tsc-wrap
1 #!/bin/bash
2 set -e
3
4 out="$1"; shift
5 tsconfig="$1"; shift
6
7 tsc_version=$(LC_ALL=C.UTF-8 tsc --version)
8
9 files_json='['
10 for f in "$@"; do
11         case "$f" in
12         *webassembly-types*)
13                 case "${tsc_version#Version }" in
14                 3.*) ;;
15                 *) continue ;;
16                 esac
17                 ;;
18         esac
19
20         files_json="${files_json}\"$f\", "
21 done
22 files_json="$files_json]"
23
24 our_tsconfig=".tsconfig.${out##*/}.json"
25
26 x () {
27     echo "+ $*" >&2;
28     "$@";
29 }
30
31 sed <"$tsconfig" >"$our_tsconfig" '/^ *"files":/ s#:.*#:'"$files_json"'#'
32
33 x tsc --outfile "$out.1.tmp" -p "$our_tsconfig" 2>&1 \
34 | perl -pe 's/\((\d+),(\d+)\):/:$1:$2:/' >&2
35 test "${PIPESTATUS[*]}" = "0 0"
36
37 sed    <"$out.1.tmp" '/^[a-z]/,$d' > "$out".tmp
38 echo "// autogenerated from $@"    >>"$out".tmp
39 sed    <"$1"         '/^[a-z]/,$d' >>"$out".tmp
40 sed -n <"$out.1.tmp" '/^[a-z]/,$p' >> "$out".tmp
41
42 mv -f "$out".tmp "$out"