From e6bf20de2fdb598c02865aef8cbf38ff18fd390b Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Mon, 19 Sep 2016 22:33:09 -0700 Subject: [PATCH] Handle stderr when using edit or config command, fixes #164 --- src/command-line/config.js | 5 ++++- src/command-line/edit.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/command-line/config.js b/src/command-line/config.js index 1fef7dde..9488d507 100644 --- a/src/command-line/config.js +++ b/src/command-line/config.js @@ -6,9 +6,12 @@ program .command("config") .description("Edit config: " + Helper.CONFIG_PATH) .action(function() { - child.spawn( + var child_spawn = child.spawn( process.env.EDITOR || "vi", [Helper.CONFIG_PATH], {stdio: "inherit"} ); + child_spawn.on("error", function() { + log.error("Unable to open " + Helper.CONFIG_PATH + ". $EDITOR is not set, and vi was not found."); + }); }); diff --git a/src/command-line/edit.js b/src/command-line/edit.js index 5d849eb9..7b2ca558 100644 --- a/src/command-line/edit.js +++ b/src/command-line/edit.js @@ -12,9 +12,12 @@ program log.error("User '" + name + "' doesn't exist."); return; } - child.spawn( + var child_spawn = child.spawn( process.env.EDITOR || "vi", [Helper.getUserConfigPath(name)], {stdio: "inherit"} ); + child_spawn.on("error", function() { + log.error("Unable to open " + Helper.getUserConfigPath(name) + ". $EDITOR is not set, and vi was not found."); + }); });