File size: 896 Bytes
402daee
 
 
 
 
eee32fb
402daee
 
 
 
 
 
 
 
 
 
 
 
 
eee32fb
402daee
 
 
 
 
 
 
 
 
 
 
 
 
 
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
-- ReaScript launcher for {{ name }}

Script = {
  name = "{{ name }}",
  host = "{{ host }}",
  protocol = "{{ protocol }}",
  lua = _VERSION:match('[%d.]+'),
  timeout = 30000,
}

function Script:load()
  local curl = "curl"
  local tempfile = os.tmpname()
  if reaper.GetOS():find("Win") then
    tempfile = os.getenv("TEMP") .. tempfile
  else
    curl = "/usr/bin/curl"
  end
  local command = curl
    .. " -sSf " .. self.protocol .. "//" .. self.host .. "/static/reascripts/" .. self.name
    .. "/" .. self.name .. "-" .. self.lua .. '.luac -o "' .. tempfile .. '"'
  local result = reaper.ExecProcess(command, self.timeout)
  local offset = result:find("\n")
  local code = tonumber(result:sub(1, offset - 1))
  local output = result:sub(offset + 1, -1)
  if code == 0 then
    loadfile(tempfile)()
  else
    reaper.ShowConsoleMsg(output)
  end
  os.remove(tempfile)
end

Script:load()