Merge pull request #622 from MaxLeiter/graceful-editor-fail

Handle stderr when using edit or config command, fixes #164
This commit is contained in:
Jérémie Astori 2016-09-25 01:31:21 -04:00 committed by GitHub
commit e568452528
2 changed files with 8 additions and 2 deletions

View File

@ -6,9 +6,12 @@ program
.command("config") .command("config")
.description("Edit config: " + Helper.CONFIG_PATH) .description("Edit config: " + Helper.CONFIG_PATH)
.action(function() { .action(function() {
child.spawn( var child_spawn = child.spawn(
process.env.EDITOR || "vi", process.env.EDITOR || "vi",
[Helper.CONFIG_PATH], [Helper.CONFIG_PATH],
{stdio: "inherit"} {stdio: "inherit"}
); );
child_spawn.on("error", function() {
log.error("Unable to open " + Helper.CONFIG_PATH + ". $EDITOR is not set, and vi was not found.");
});
}); });

View File

@ -12,9 +12,12 @@ program
log.error("User '" + name + "' doesn't exist."); log.error("User '" + name + "' doesn't exist.");
return; return;
} }
child.spawn( var child_spawn = child.spawn(
process.env.EDITOR || "vi", process.env.EDITOR || "vi",
[Helper.getUserConfigPath(name)], [Helper.getUserConfigPath(name)],
{stdio: "inherit"} {stdio: "inherit"}
); );
child_spawn.on("error", function() {
log.error("Unable to open " + Helper.getUserConfigPath(name) + ". $EDITOR is not set, and vi was not found.");
});
}); });