UNPKG

849 BJavaScriptView Raw
1"use strict";
2
3const program = require("commander");
4const child = require("child_process");
5const colors = require("colors/safe");
6const fs = require("fs");
7const Helper = require("../helper");
8const Utils = require("./utils");
9
10program
11 .command("config")
12 .description(`Edit configuration file located at ${colors.green(Helper.getConfigPath())}.`)
13 .on("--help", Utils.extraHelp)
14 .action(function() {
15 if (!fs.existsSync(Helper.getConfigPath())) {
16 log.error(`${Helper.getConfigPath()} does not exist.`);
17 return;
18 }
19
20 var child_spawn = child.spawn(
21 process.env.EDITOR || "vi",
22 [Helper.getConfigPath()],
23 {stdio: "inherit"}
24 );
25 child_spawn.on("error", function() {
26 log.error(`Unable to open ${colors.green(Helper.getConfigPath())}. ${colors.bold("$EDITOR")} is not set, and ${colors.bold("vi")} was not found.`);
27 });
28 });