This repository has been archived on 2021-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
pyRCV2/build.sh

17 lines
1.1 KiB
Bash
Raw Normal View History

2020-10-17 18:40:18 +11:00
#!/bin/env bash
2020-10-17 22:20:13 +11:00
# Transcrypt
transcrypt $@ --nomin pyRCV2.transcrypt || exit 1
# Patch next() to accept optional argument
perl -0777 -i -pe 's#function py_next \(iterator\) {#function py_next \(iterator, def = undefined\) { try { return py_next_orig \(iterator\); } catch \(exception\) { if \(def !== "undefined"\) { return def; } else { throw exception; } } } function py_next_orig \(iterator\) {#g' __target__/org.transcrypt.__runtime__.js || exit 1
# Patch sum() to accept optional argument
perl -0777 -i -pe 's#export function sum \(iterable\) {\n let result = 0;#export function sum \(iterable, result = 0\) { for \(let item of iterable\) { result = __add__\(result, item\); } return result;#g' __target__/org.transcrypt.__runtime__.js || exit 1
# Patch sort() to use operator overloading
perl -0777 -i -pe 's#key \(a\) > key \(b\) \?#__gt__\(key \(a\), key \(b\)\) \?#g' __target__/org.transcrypt.__runtime__.js || exit 1
# Roll up
rollup __target__/pyRCV2.transcrypt.js -o bundle.js --name py -f iife --no-treeshake || exit 1
# Patch
perl -0777 -i -pe "s#'__index0__'#__index0__#g" bundle.js || exit 1