Revise KissConfig

This commit is contained in:
2021-10-19 13:55:20 -04:00
parent a2f5dcf92a
commit d36555c603
3 changed files with 18 additions and 13 deletions

View File

@@ -5,13 +5,16 @@ import kiss.Prelude;
import kiss.Stream; import kiss.Stream;
import vscode.*; import vscode.*;
import js.lib.Promise; import js.lib.Promise;
import js.node.ChildProcess;
import hscript.Parser; import hscript.Parser;
import hscript.Interp; import hscript.Interp;
import hscript.Expr; import hscript.Expr;
import haxe.io.Path; import haxe.io.Path;
import sys.io.File; import sys.io.File;
import sys.FileSystem;
using haxe.io.Path; using haxe.io.Path;
using StringTools;
typedef Command = (String) -> Void; typedef Command = (String) -> Void;

View File

@@ -1,3 +1,5 @@
(load "Util.kiss")
(function userHome [] (or (Sys.getEnv "MSYSHOME") (Sys.getEnv "HOME") (Sys.getEnv "UserProfile"))) (function userHome [] (or (Sys.getEnv "MSYSHOME") (Sys.getEnv "HOME") (Sys.getEnv "UserProfile")))
(function userConfigDir [] (function userConfigDir []
(joinPath (joinPath
@@ -9,19 +11,6 @@
(var &mut builtinConfigDir "") (var &mut builtinConfigDir "")
(var &mut :KissConfig config null) (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] (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 // 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 (let [handleConfigFailure

View File

@@ -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))))))