mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-08 09:42:55 -04:00
41 lines
1.7 KiB
Lua
41 lines
1.7 KiB
Lua
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
|
|
local osName, fused, command = "Windows", true, nil
|
|
love = {
|
|
system = { getOS = function() return osName end },
|
|
filesystem = {
|
|
getExecutablePath = function() return "C:\\Game\\gen1recomp.exe" end,
|
|
getSource = function() return "C:\\Source\\gen1recomp" end,
|
|
isFused = function() return fused end,
|
|
},
|
|
}
|
|
package.loaded["src.core.Platform"] = { canSpawnProcess = function() return true end }
|
|
local realWinApi = require("src.core.WinApi")
|
|
local spawned = nil
|
|
package.loaded["src.core.WinApi"] = {
|
|
dirOf = realWinApi.dirOf,
|
|
spawn = function(exe, args, opts) spawned = { exe = exe, args = args, opts = opts } return true end,
|
|
}
|
|
local execute = os.execute
|
|
os.execute = function(value) command = value return 0 end
|
|
|
|
local HostShell = require("src.core.HostShell")
|
|
assert(HostShell.spawnSelfDetached({ "--display-companion=50000,token" }))
|
|
assert(command == nil, "Windows never goes through cmd.exe")
|
|
assert(spawned and spawned.exe == "C:\\Game\\gen1recomp.exe"
|
|
and #spawned.args == 1 and spawned.args[1] == "--display-companion=50000,token"
|
|
and spawned.opts.cwd == "C:\\Game",
|
|
"Windows launches the fused app through the wide spawner")
|
|
|
|
osName, fused = "Linux", false
|
|
assert(HostShell.spawnSelfDetached({ "--display-companion=50000,token" }))
|
|
assert(command:find("'C:\\Source\\gen1recomp'", 1, true)
|
|
and command:sub(-1) == "&", "Linux source runs include the game folder")
|
|
|
|
osName, fused = "OS X", true
|
|
assert(HostShell.spawnSelfDetached({ "--display-companion=50000,token" }))
|
|
assert(not command:find("start", 1, true) and command:sub(-1) == "&",
|
|
"macOS uses the same detached POSIX path")
|
|
os.execute = execute
|
|
print("spawn self detached: ok")
|