-
Notifications
You must be signed in to change notification settings - Fork 3
/
Install.py
60 lines (51 loc) · 2.06 KB
/
Install.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import subprocess
import sys
import os
def command_exists(command):
proc = subprocess.Popen(["hash", command], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return proc.stderr.read() == b''
if not command_exists("node"):
if len(sys.argv) < 2:
print("Run as python3 Make.py <package manager>")
sys.exit(1)
PACKAGE = " ".join(sys.argv[1:])
if not command_exists(PACKAGE.split(" ")[0]):
print("Can't find package manager %s. Some common ones to try are brew install (mac), apt-get install (most linux distros)")
sys.exit(1)
print("Node not installed, install it?")
res = input("[Y/n]")
if res == "n":
print("Cancelling installation")
sys.exit(1)
inst = subprocess.Popen((PACKAGE + " nodejs").split())
if inst.wait():
print("nodejs not found, trying node.js instead...")
inst = subprocess.Popen((PACKAGE + " node.js").split())
if not command_exists("elm"):
if len(sys.argv) < 2:
print("Run as python3 Make.py <package manager>")
sys.exit(1)
PACKAGE = " ".join(sys.argv[1:])
if not command_exists(PACKAGE.split(" ")[0]):
print("Can't find package manager %s. Some common ones to try are brew install (mac), apt-get install (most linux distros)")
sys.exit(1)
print("Elm not installed, install it?")
res = input("[Y/n]")
if res == "n":
print("Cancelling installation")
sys.exit(1)
inst = subprocess.Popen((PACKAGE + " elm").split())
for module in "ws", "ip":
a = subprocess.Popen(["npm", "ls", module], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
errorCode = a.wait()
if errorCode != 0:
print("%s isn't installed. Install it?" % module)
res = input("[Y/n]")
if res == "n":
print("Cancelling installation")
sys.exit(1)
subprocess.run(["npm", "install", module])
if not os.path.isdir("UglifyJS"):
res = input("Install uglifyjs? (Not requiered) [y/N] ").lower()
if res == "y":
os.system("git clone git://github.com/mishoo/UglifyJS.git")