Skip to content

Commit

Permalink
better compress timeago locales
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Apr 26, 2022
1 parent 08b8aca commit 8f77cb1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
7 changes: 4 additions & 3 deletions bin/gen/timeago-to-scala.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import os.path
import subprocess
import sys
import re


def main(args):
Expand Down Expand Up @@ -73,18 +74,18 @@ def main(args):


def terser(js):
p = subprocess.Popen(["yarn", "run", "--silent", "terser", "--mangle", "--compress", "--safari10"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=sys.stderr)
p = subprocess.Popen(["yarn", "run", "--silent", "terser", "--mangle", "--compress", "--toplevel", "--safari10"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=sys.stderr)
stdout, stderr = p.communicate(js.encode("utf-8"))
if p.returncode != 0:
sys.exit(p.returncode)
return stdout.decode("utf-8")


def preprocess(js):
return js.replace("export default function", "lichess.timeagoLocale=function");
return re.sub(r"export default function ([^\{]+)\{", r"lichess.timeagoLocale = \1=> {", js)

def postprocess(js):
return "(function(){" + js.strip() + "})()"
return "{" + js.strip() + "}"



Expand Down
Loading

0 comments on commit 8f77cb1

Please sign in to comment.