mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-13 19:04:54 +01:00
Try to fix web-shell when called from Godot
This commit is contained in:
parent
a1bb607c7e
commit
5ff4ca6c28
7 changed files with 11 additions and 11 deletions
|
@ -108,6 +108,7 @@ func load_state():
|
|||
|
||||
# filename is relative to the tmp directory!
|
||||
func create_file_in_game_env(filename, content):
|
||||
print("CD-ing to tmp in create_file")
|
||||
await global_shell.cd(tmp_prefix)
|
||||
# Quoted HERE doc doesn't do any substitutions inside.
|
||||
await global_shell.run("cat > '%s' <<'HEREHEREHERE'\n%s\nHEREHEREHERE" % [filename, content])
|
||||
|
|
|
@ -102,6 +102,7 @@ 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:
|
||||
print("CD-ing to tmp in careful_delete")
|
||||
await game.global_shell.cd(game.tmp_prefix)
|
||||
await game.global_shell.run("rm -rf '%s'" % path_inside)
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ func set_path(new_path):
|
|||
if path_node:
|
||||
path_node.text = path
|
||||
if new_path != "":
|
||||
print("CD-ing repo shell to " + new_path)
|
||||
shell.cd(new_path)
|
||||
for o in objects.values():
|
||||
o.queue_free()
|
||||
|
|
|
@ -20,14 +20,13 @@ func cd(dir):
|
|||
# Run a shell command given as a string. Run this if you're interested in the
|
||||
# output of the command.
|
||||
func run(command, crash_on_fail=true):
|
||||
print("run " + command)
|
||||
var shell_command = ShellCommand.new()
|
||||
shell_command.command = command
|
||||
shell_command.crash_on_fail = crash_on_fail
|
||||
|
||||
run_async_thread(shell_command)
|
||||
await shell_command.done
|
||||
print("output in run (" +command+ "): " + shell_command.output)
|
||||
print("output of (" +command+ "): >>" + shell_command.output + "<<")
|
||||
exit_code = shell_command.exit_code
|
||||
return shell_command.output
|
||||
|
||||
|
@ -39,7 +38,6 @@ func run_async_web(command, crash_on_fail=true):
|
|||
return shell_command
|
||||
|
||||
func run_async_thread(shell_command):
|
||||
print("in async thread " + shell_command.command)
|
||||
var debug = false
|
||||
|
||||
var command = shell_command.command
|
||||
|
@ -58,6 +56,8 @@ func run_async_thread(shell_command):
|
|||
hacky_command += "export PATH=\'"+game.tmp_prefix+":'\"$PATH\";"
|
||||
hacky_command += "cd '%s' || exit 1;" % _cwd
|
||||
hacky_command += command
|
||||
|
||||
print("running >>" + hacky_command + "<<")
|
||||
|
||||
var result
|
||||
if _os == "Linux" or _os == "OSX":
|
||||
|
@ -95,7 +95,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(hacky_command).then(shell_command.js_callback)
|
||||
else:
|
||||
helpers.crash("Unimplemented OS: %s" % _os)
|
||||
|
||||
|
@ -115,9 +115,6 @@ func _shell_binary():
|
|||
else:
|
||||
helpers.crash("Unsupported OS: %s" % _os)
|
||||
|
||||
func callback(args):
|
||||
print(args)
|
||||
|
||||
func read_from(c):
|
||||
var total_available = c.get_available_bytes()
|
||||
print(str(total_available)+" bytes available")
|
||||
|
|
|
@ -16,7 +16,7 @@ func _unused():
|
|||
|
||||
func callback(_output):
|
||||
#print(_output)
|
||||
print(_output[0])
|
||||
output = _output[0]
|
||||
print("output of async command (" + command + "): >>"+output+"<<" )
|
||||
exit_code = 0
|
||||
emit_signal("done")
|
||||
|
|
|
@ -90,7 +90,6 @@ func send_command(command):
|
|||
|
||||
shell.cd(repository.path)
|
||||
|
||||
print("running " + command)
|
||||
var cmd = shell.run_async_web(command, false)
|
||||
await cmd.done
|
||||
call_deferred("command_done", cmd)
|
||||
|
|
|
@ -112,9 +112,10 @@ function boot() {
|
|||
emulator = window["emulator"] = new V86Starter(config)
|
||||
|
||||
// Wait for the emulator to start, then resolve the promise.
|
||||
var interval = setInterval(() => {
|
||||
var interval = setInterval(async () => {
|
||||
if (emulator.is_running()) {
|
||||
run("PS1='# '")
|
||||
await run("PS1='# '")
|
||||
await run("stty -echo")
|
||||
clearInterval(interval)
|
||||
resolve(true)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue