17 lines
1.1 KiB
Bash
Executable File
17 lines
1.1 KiB
Bash
Executable File
#!/bin/env bash
|
|
# 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
|