40 lines
984 B
Plaintext
40 lines
984 B
Plaintext
|
use std
|
||
|
|
||
|
if (ARGS.length >= 2 && ARGS[0] == "owm") {
|
||
|
use files, json, java
|
||
|
|
||
|
File = newClass("java.io.File")
|
||
|
runtime = newClass("java.lang.Runtime").getRuntime()
|
||
|
|
||
|
def loadModulesJson(path = "modules.json") {
|
||
|
f = fopen(path, "r")
|
||
|
modules = jsondecode(readText(f))
|
||
|
fclose(f)
|
||
|
return modules
|
||
|
}
|
||
|
def exec(cmd, dir = ".") = runtime.exec(cmd, null, new File(dir))
|
||
|
|
||
|
match (ARGS[1]) {
|
||
|
case "install": {
|
||
|
modulesDir = "own-modules"
|
||
|
if (!exists(modulesDir)) {
|
||
|
mkdir(modulesDir)
|
||
|
}
|
||
|
for module : loadModulesJson() {
|
||
|
print module.name
|
||
|
moduleDir = modulesDir + "/" + module.name
|
||
|
if (!exists(moduleDir)) {
|
||
|
mkdir(moduleDir)
|
||
|
cmd = "git clone https://gist.github.com/" + module.id + ".git " + module.name
|
||
|
exec(cmd, modulesDir)
|
||
|
println " installed"
|
||
|
} else {
|
||
|
exec("git pull origin master", moduleDir)
|
||
|
println " updated"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|