#!/usr/bin/env python3

import glob
import os
import shutil
import sys

if os.name == "nt":
    uglifyjs = os.path.abspath("../lib/uglifyjs.cmd")
else:
    uglifyjs = "uglifyjs"

if shutil.which(uglifyjs) is None:
    print("Cannot find executable: {0}".format(uglifyjs))
    sys.exit(1)

input_dir = os.path.abspath("./Resources/Tracker/scripts")
output_dir = os.path.abspath("./Resources/Tracker/scripts.min")

for file in glob.glob(input_dir + "/*.js"):
    name = os.path.basename(file)
    print("Minifying {0}...".format(name))
    os.system("{0} {1} -o {2}/{3}".format(uglifyjs, file, output_dir, name))

print("Done!")

# Python 3

import glob
import os

uglifyjs = os.path.abspath("../lib/uglifyjs")
input_dir = os.path.abspath("./Resources/Tracker/scripts")
output_dir = os.path.abspath("./Resources/Tracker/scripts.min")

for file in glob.glob(input_dir + "/*.js"):
    name = os.path.basename(file)
    print("Minifying {0}...".format(name))
    os.system("{0} {1} -o {2}/{3}".format(uglifyjs, file, output_dir, name))

print("Done!")

--- 
+++ 
@@ -1,9 +1,19 @@
-# Python 3
+#!/usr/bin/env python3
 
 import glob
 import os
+import shutil
+import sys
 
-uglifyjs = os.path.abspath("../lib/uglifyjs")
+if os.name == "nt":
+    uglifyjs = os.path.abspath("../lib/uglifyjs.cmd")
+else:
+    uglifyjs = "uglifyjs"
+
+if shutil.which(uglifyjs) is None:
+    print("Cannot find executable: {0}".format(uglifyjs))
+    sys.exit(1)
+
 input_dir = os.path.abspath("./Resources/Tracker/scripts")
 output_dir = os.path.abspath("./Resources/Tracker/scripts.min")
 
Fix app minification script on non-Windows systems
