File: txt2js.sh

package info (click to toggle)
dygraphs 2.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,340 kB
  • sloc: javascript: 24,842; sh: 800; python: 581; makefile: 45
file content (28 lines) | stat: -rwxr-xr-x 704 bytes parent folder | download
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
#!/bin/mksh
# © 2022 mirabilos <t.glaser@tarent.de> Ⓕ MIT

set -eo pipefail
case $KSH_VERSION {
(*MIRBSD\ KSH*) ;;
(*) echo E: do not call me with bash or something; exit 255 ;;
}
mydir=$(realpath "$0/..")

infile=$1
outfile=$2
if [[ -z $infile || ! -s $infile || -z $outfile ]]; then
	print -ru2 "E: syntax error"
	exit 1
fi

if command -v nodejs >/dev/null 2>&1; then
	node_js=nodejs
else
	node_js=node
fi

rm -f "$outfile" "$outfile.tmp.js" "$outfile.tmp.js.map"
print -ru2 "I: converting $infile to $outfile"
$node_js "$mydir"/txt2js.js "$infile" "$outfile.tmp.js"
python3 "$mydir"/smap-in.py "$outfile.tmp.js" "$outfile.tmp.js.map" "$outfile" --nonl
rm -f "$outfile.tmp.js" "$outfile.tmp.js.map"