Halfway through making everything async...

This commit is contained in:
blinry 2023-09-07 12:04:47 +02:00
parent ad8d8f50d1
commit 19fcad2920
6 changed files with 18 additions and 16 deletions

View file

@ -45,7 +45,7 @@ func update():
clear()
# Files in the working directory.
var wd_files = Array(repository.shell.run("find . -type f -not -path '*/\\.git/*'").split("\n"))
var wd_files = Array((await repository.shell.run("find . -type f -not -path '*/\\.git/*'")).split("\n"))
# The last entry is an empty string, remove it.
wd_files.pop_back()
wd_files = helpers.map(wd_files, self, "substr2")

View file

@ -44,14 +44,15 @@ func _ready():
# print(cmd)
# helpers.crash(":)")
if global_shell.run("command -v git &>/dev/null && echo yes || echo no") == "no\n":
game.skipped_title = true
get_tree().change_scene_to_file("res://scenes/no_git.tscn")
else:
create_file_in_game_env(".gitconfig", helpers.read_file("res://scripts/gitconfig"))
copy_script_to_game_env("fake-editor")
copy_script_to_game_env("hint")
if false:
if global_shell.run("command -v git &>/dev/null && echo yes || echo no") == "no\n":
game.skipped_title = true
get_tree().change_scene_to_file("res://scenes/no_git.tscn")
else:
create_file_in_game_env(".gitconfig", helpers.read_file("res://scripts/gitconfig"))
copy_script_to_game_env("fake-editor")
copy_script_to_game_env("hint")
func start_remote_shell():
var user_dir = ProjectSettings.globalize_path("user://")

View file

@ -102,8 +102,8 @@ func careful_delete(path_inside):
if path_inside.substr(0,expected_prefix.length()) != expected_prefix:
helpers.crash("Refusing to delete directory %s that does not start with %s" % [path_inside, expected_prefix])
else:
game.global_shell.cd(game.tmp_prefix)
game.global_shell.run("rm -rf '%s'" % path_inside)
await game.global_shell.cd(game.tmp_prefix)
await game.global_shell.run("rm -rf '%s'" % path_inside)
func parse(file):
var text = read_file(file)

View file

@ -49,7 +49,7 @@ func _unhandled_input(event):
nodes.scale += Vector2(0.05, 0.05)
func there_is_a_git():
return shell.run("test -d .git && echo yes || echo no") == "yes\n"
return await shell.run("test -d .git && echo yes || echo no") == "yes\n"
func update_everything():
there_is_a_git_cache = there_is_a_git()
@ -140,7 +140,7 @@ func update_objects():
func update_node_positions():
if there_is_a_git_cache:
var graph_text = shell.run("git log --graph --oneline --all --no-abbrev")
var graph_text = await shell.run("git log --graph --oneline --all --no-abbrev")
var graph_lines = Array(graph_text.split("\n"))
graph_lines.pop_back()
@ -214,7 +214,7 @@ func find_position(n):
return n.position
func git(args, splitlines = false):
var o = shell.run("git --no-replace-objects " + args)
var o = await shell.run("git --no-replace-objects " + args)
if splitlines:
o = o.split("\n")

View file

@ -25,6 +25,7 @@ func run(command, crash_on_fail=true):
shell_command.crash_on_fail = crash_on_fail
run_async_thread(shell_command)
await shell_command.done
exit_code = shell_command.exit_code
return shell_command.output
@ -102,7 +103,7 @@ func run_async_thread(shell_command):
#print(hacky_command)
shell_command.js_callback = JavaScriptBridge.create_callback(Callable(shell_command, "callback"))
web_shell.run_in_vm(hacky_command).then(shell_command.js_callback)
web_shell.run_in_vm(command).then(shell_command.js_callback)
else:
helpers.crash("Unimplemented OS: %s" % _os)

View file

@ -200,7 +200,7 @@ func generate_completions(command):
# Part2: Prevent autocompletion to only show filename at the beginning of a command.
if !(command.substr(0,4) == "git " and command.split(" ").size() <= 2) and command.split(" ").size() > 1:
var last_word = Array(command.split(" ")).pop_back()
var file_string = repository.shell.run("find . -type f")
var file_string = await repository.shell.run("find . -type f")
var files = file_string.split("\n")
files = Array(files)
# The last entry is an empty string, remove it.