1 | "use strict";
|
2 |
|
3 | const program = require("commander");
|
4 | const child = require("child_process");
|
5 | const colors = require("colors/safe");
|
6 | const fs = require("fs");
|
7 | const Helper = require("../helper");
|
8 | const Utils = require("./utils");
|
9 |
|
10 | program
|
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 | });
|