-
Notifications
You must be signed in to change notification settings - Fork 15
Separate downloading and installation #12
base: master
Are you sure you want to change the base?
Conversation
| if status then | ||
| makeFile(path, response) | ||
| else | ||
| printError(('Unable to download %s'):format(path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line would never actually be hit before anyway!
499d311 to
996dff6
Compare
install
Outdated
|
|
||
| for _, prog in pairs(fs.list('programs')) do | ||
| local f = fs.open('/'..prog, 'w') | ||
| f.write([[loadfile('%s', getfenv())()]]:format(dest_dir..'/programs/'..prog)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out loadfile takes an env as an argument, so this becomes a simple one-liner
| -- Easy installer. Bootstrapped by http://pastebin.com/p8PJVxC4 | ||
|
|
||
| local base_url, dest = select(1,...) | ||
| dest = dest or 'computercraft-github' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps cc-git-src would be better here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you're essentially creating here is a custom rom... I think the best default would be github.rom.
|
doesn't work. I think the problem is with your pastebin script: > pastebin run zDAQHQdz seperate-install-download
Connecting to pastebin.com... Success.
ZDAQHQdz:9: bad argument: String expected, got table
>also if you register for a pastebin account, and create the paste under your account you can edit it and what not and not have to update the pasetbin id here in the project. |
|
Yep, should be: loadstring doesn't take an env, unlike loadfile. Maybe I don't need the env anyway? |
|
I didn't On Fri, Aug 26, 2016, 18:31 Eric Wieser notifications@github.com wrote:
|
|
@mention me when your ready for another test. On Fri, Aug 26, 2016, 20:13 Aaron Allen aaronmallen4@gmail.com wrote:
|
|
|
@aaronmallen: How about now? |
|
attempt to index a nil value line 5 of the pastebin |
|
The pastebin didn't change? I think you got unlucky, and the http request failed |
|
well then Im continually getting unlucky... its happened about 6 times now :) you could always load up an instance of CC and test away... |
|
Yeah, I didn't really want to have to do that, but I guess I ought to. I just updated it with an assertion. It sounds like the Does it give different output now? |
|
no it looks like Ive reached the gh api limit... |
|
Then yes, I'd say go ahead with trying to make auth work! |
|
would be nice to have #11 merged before working on that. |
| } | ||
|
|
||
| local function request(url_path) | ||
| local request = http.get(base_url..'/'..url_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work as expected. For some reason if request fails CC is making request = nil. We should mimic what we did in the getAPI method:
local request = http.get(base_url..'/'..url_path)
local success = false
local response = nil
if request then
success = request.getResponseCode() == 200
response = request.readAll()
request.close()
end
return success, response
| end | ||
| status, response = request(path) | ||
| try = try + 1 | ||
| until status ~= 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use my recommended change above this would need to be
until status
| w.close() | ||
| end | ||
|
|
||
| for _, folder in ipairs({'api', 'programs'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better served as a table like what we do with FILES instead of hardcoded here.
So that you can update without needing pastebin any more
Instead of creating
github.rom, this creates a_builddirectory inside wherever you downloaded the script to, within which it places copies of apis and programs with their dofiles rewritten.@aaronmallen, can I get you to test this?