From d0490cd4cb4e99ec7820b621482846d7a377a18e Mon Sep 17 00:00:00 2001 From: osmarks Date: Thu, 26 Jul 2018 10:59:05 +0100 Subject: [PATCH] Fix installer --- installer.lua | 23 +++++++++++------------ luadash.lua | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/installer.lua b/installer.lua index 3402bf1..9bf4d46 100644 --- a/installer.lua +++ b/installer.lua @@ -1,25 +1,24 @@ -local d = _ or require "luadash" +local d = require "luadash" or _ local wyvern_files = { root = "https://osmarks.tk/git/osmarks/wyvern/raw/branch/master/", files = { "installer.lua", "luadash.lua", "lib.lua" } } -local ccfuse_files = { - root = "https://raw.githubusercontent.com/apemanzilla/ccfuse/master/client/", - files = { "base64.lua", "json.lua", "ccfuse.lua" } -} - local args = {...} -local command = d.head(args) +local command = args[1] -- native luadash head is broken local params = d.tail(args) -local function download_files(urls) - d.map(urls, function(urls) shell.run("wget", url) end) -- TODO: stop using wget and use actual HTTP/FS API -end - local function download_group(g) - download_files(d.map(g.files, function(file) return g.root .. file end)) + d.map(g.files, function(file) + local url = g.root .. file + local h = http.get(url) + local contents = h.readAll() + local f = fs.open(file, "w") + f.write(contents) + f.close() + print("Written", file, "from", url) + end) end local function prompt(msg) diff --git a/luadash.lua b/luadash.lua index 3e6ff0d..b75eb00 100644 --- a/luadash.lua +++ b/luadash.lua @@ -205,7 +205,7 @@ end function _.head(t) _.expect('head', 1, 'table', t) - return x[1] + return t[1] end function _.tail(t)