Add some switches that set proper paths for Windows

This commit is contained in:
Sebastian Morr 2020-09-09 11:48:42 +02:00
parent d352bd24c2
commit 724a5fff03
3 changed files with 27 additions and 14 deletions

21
game.gd
View File

@ -1,12 +1,18 @@
extends Node
var tmp_prefix = "/tmp/"
var tmp_prefix = _tmp_prefix()
var global_shell
var debug = false
var fake_editor
func _ready():
global_shell = Shell.new()
global_shell.cd(tmp_prefix)
# Copy fake-editor to tmp directory (because the original might be in a .pck file).
var fake_editor = tmp_prefix + "fake-editor"
var content = game.read_file("res://scripts/fake-editor")
write_file(fake_editor, content)
global_shell.run("chmod u+x " + fake_editor)
func read_file(path):
if debug:
@ -25,3 +31,14 @@ func write_file(path, content):
file.store_string(content)
file.close()
return true
func _tmp_prefix():
var os = OS.get_name()
if os == "X11":
return "/tmp/"
elif os == "Windows":
return "%temp%/"
else:
push_error("Unsupported OS")
get_tree().quit()

10
main.gd
View File

@ -83,11 +83,11 @@ func construct_repo(script, path):
var script_path = game.tmp_prefix+"/git-hydra-script"
game.write_file(script_path, content)
var shell = Shell.new()
shell.run("mkdir " + path)
shell.cd(path)
shell.run("git init")
var o = shell.run("source "+script_path)
game.global_shell.run("mkdir " + path)
game.global_shell.cd(path)
game.global_shell.run("git init")
var o = game.global_shell.run("source "+script_path)
if game.debug:
print(o)

View File

@ -7,11 +7,7 @@ var _fake_editor
signal output(text)
func _init():
# Copy fake-editor to tmp directory (because the original might be in a .pck file).
_fake_editor = game.tmp_prefix + "fake-editor"
var content = game.read_file("res://scripts/fake-editor")
game.write_file(_fake_editor, content)
_exec("chmod", ["u+x", _fake_editor])
_cwd = game.tmp_prefix
func cd(dir):
_cwd = dir
@ -44,9 +40,9 @@ func _shell_binary():
var os = OS.get_name()
if os == "X11":
return "/bin/sh"
return "sh"
elif os == "Windows":
return "external/git_bash.exe"
return "sh.exe"
else:
push_error("Unsupported OS")
get_tree().quit()