mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-11 19:04:50 +01:00
First Windows Fixes
This commit is contained in:
parent
40ec539e49
commit
b044ed5d27
3 changed files with 16 additions and 22 deletions
18
game.gd
18
game.gd
|
@ -13,14 +13,15 @@ var state = {}
|
|||
|
||||
func _ready():
|
||||
var dir = Directory.new()
|
||||
var repo_dir = tmp_prefix_outside+"repos/"
|
||||
if not dir.dir_exists(tmp_prefix_outside):
|
||||
var err = dir.make_dir(tmp_prefix_outside)
|
||||
if err != OK:
|
||||
helpers.crash("Could not create temporary directory %s." % tmp_prefix_outside)
|
||||
if not dir.dir_exists(tmp_prefix_outside+"/repos/"):
|
||||
var err = dir.make_dir(tmp_prefix_outside+"/repos/")
|
||||
if not dir.dir_exists(repo_dir):
|
||||
var err = dir.make_dir(repo_dir)
|
||||
if err != OK:
|
||||
helpers.crash("Could not create temporary directory %s." % (tmp_prefix_outside+"/repos/"))
|
||||
helpers.crash("Could not create temporary directory %s." % repo_dir)
|
||||
|
||||
global_shell = Shell.new()
|
||||
fake_editor = copy_file_to_game_env("fake-editor")
|
||||
|
@ -60,16 +61,7 @@ func copy_file_to_game_env(filename):
|
|||
return file_inside
|
||||
|
||||
func _tmp_prefix_inside():
|
||||
var os = OS.get_name()
|
||||
var path
|
||||
if os == "X11" or os == "OSX":
|
||||
path = OS.get_user_data_dir()
|
||||
elif os == "Windows":
|
||||
helpers.crash("Need to figure out Windows tmp_prefix_inside...")
|
||||
else:
|
||||
helpers.crash("Unsupported OS: %s" % os)
|
||||
|
||||
return path + "/tmp/"
|
||||
return OS.get_user_data_dir() + "/tmp/"
|
||||
|
||||
func _tmp_prefix_outside():
|
||||
return "user://tmp/"
|
||||
|
|
11
helpers.gd
11
helpers.gd
|
@ -21,12 +21,11 @@ func exec(command, args=[], crash_on_fail=true):
|
|||
var output = []
|
||||
var exit_code = OS.execute(command, args, true, output, true)
|
||||
output = output[0]
|
||||
|
||||
|
||||
if exit_code != 0 and crash_on_fail:
|
||||
helpers.crash("OS.execute failed: %s [%s] Output: %s" % [command, PoolStringArray(args).join(", "), output])
|
||||
|
||||
if debug:
|
||||
print(output)
|
||||
helpers.crash("OS.execute failed: %s [%s] Output: %s \nExit Code %d" % [command, PoolStringArray(args).join(", "), output, exit_code])
|
||||
elif debug:
|
||||
print("Output: %s" %output)
|
||||
|
||||
return output
|
||||
|
||||
|
@ -78,7 +77,7 @@ func careful_delete(path_inside):
|
|||
elif os == "OSX":
|
||||
expected_prefix = "/Users/%s/Library/Application Support/git-hydra/tmp/" % OS.get_environment("USER")
|
||||
elif os == "Windows":
|
||||
helpers.crash("Need to figure out delete_prefix on Windows")
|
||||
expected_prefix = "C:/Users/%s/AppData/Roaming/git-hydra/tmp/" % OS.get_environment("USERNAME")
|
||||
else:
|
||||
helpers.crash("Unsupported OS: %s" % os)
|
||||
|
||||
|
|
9
shell.gd
9
shell.gd
|
@ -2,6 +2,7 @@ extends Node
|
|||
class_name Shell
|
||||
|
||||
var _cwd
|
||||
var os = OS.get_name()
|
||||
|
||||
#signal output(text)
|
||||
|
||||
|
@ -47,8 +48,10 @@ func run(command, crash_on_fail=true):
|
|||
# becomes
|
||||
#
|
||||
# "'test '"'"'fu'"'"' "bla" blubb"
|
||||
#
|
||||
hacky_command = '"\''+hacky_command.replace("'", "'\"'\"'")+'\'"'
|
||||
#
|
||||
# Quoting Magic is not needed for Windows!
|
||||
if os == "X11" or os == "OSX":
|
||||
hacky_command = '"\''+hacky_command.replace("'", "'\"'\"'")+'\'"'
|
||||
|
||||
var output = helpers.exec(_shell_binary(), ["-c", hacky_command], crash_on_fail)
|
||||
|
||||
|
@ -58,7 +61,7 @@ func run(command, crash_on_fail=true):
|
|||
return output
|
||||
|
||||
func _shell_binary():
|
||||
var os = OS.get_name()
|
||||
|
||||
|
||||
if os == "X11" or os == "OSX":
|
||||
return "bash"
|
||||
|
|
Loading…
Reference in a new issue