From d36555c60301f490177a60d8ca6377ce4133c330 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 19 Oct 2021 13:55:20 -0400 Subject: [PATCH] Revise KissConfig --- projects/kiss-vscode/config/KissConfig.hx | 3 +++ projects/kiss-vscode/src/Main.kiss | 15 ++------------- projects/kiss-vscode/src/Util.kiss | 13 +++++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 projects/kiss-vscode/src/Util.kiss diff --git a/projects/kiss-vscode/config/KissConfig.hx b/projects/kiss-vscode/config/KissConfig.hx index b299b13f..1d260167 100644 --- a/projects/kiss-vscode/config/KissConfig.hx +++ b/projects/kiss-vscode/config/KissConfig.hx @@ -5,13 +5,16 @@ import kiss.Prelude; import kiss.Stream; import vscode.*; import js.lib.Promise; +import js.node.ChildProcess; import hscript.Parser; import hscript.Interp; import hscript.Expr; import haxe.io.Path; import sys.io.File; +import sys.FileSystem; using haxe.io.Path; +using StringTools; typedef Command = (String) -> Void; diff --git a/projects/kiss-vscode/src/Main.kiss b/projects/kiss-vscode/src/Main.kiss index 3a9f045c..d0d9be0f 100644 --- a/projects/kiss-vscode/src/Main.kiss +++ b/projects/kiss-vscode/src/Main.kiss @@ -1,3 +1,5 @@ +(load "Util.kiss") + (function userHome [] (or (Sys.getEnv "MSYSHOME") (Sys.getEnv "HOME") (Sys.getEnv "UserProfile"))) (function userConfigDir [] (joinPath @@ -9,19 +11,6 @@ (var &mut builtinConfigDir "") (var &mut :KissConfig config null) -// This has to be a macro so it can return from tryLoadConfig -(defMacro trySpawnSync [command args options onError] - `(let [command ,command - args ,args - result (ChildProcess.spawnSync command args ,options)] - (if result.error - (throw "Error $result.error from $command $args: $result.stdout $result.stderr") - (case result.status - (0 null) - (errCode - (,onError "Error code $errCode from $command $args: $result.stdout $result.stderr") - (return)))))) - (function :Void tryLoadConfig [&opt :String text] // TODO if a config object is active and a shortcut panel is open, dispose the panel before we lose the handle in the current config object (let [handleConfigFailure diff --git a/projects/kiss-vscode/src/Util.kiss b/projects/kiss-vscode/src/Util.kiss new file mode 100644 index 00000000..ccd9b5fc --- /dev/null +++ b/projects/kiss-vscode/src/Util.kiss @@ -0,0 +1,13 @@ +// This has to be a macro so it can return from tryLoadConfig +(defMacro trySpawnSync [command args options onError] + `(let [command ,command + args ,args + options ,options + result (ChildProcess.spawnSync command args options)] + (if result.error + (throw "Error $result.error from $command ${args}: $result.stdout $result.stderr") + (case result.status + (0 null) + (errCode + (,onError "Error code $errCode from $command ${args}: $result.stdout $result.stderr") + (return)))))) \ No newline at end of file