mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 12:03:11 +00:00
Fix up commander changes
This commit is contained in:
parent
b000a594f4
commit
80b0e8ad12
5 changed files with 9 additions and 22 deletions
|
@ -16,12 +16,6 @@ program
|
||||||
"override entries of the configuration file, must be specified for each entry that needs to be overriden",
|
"override entries of the configuration file, must be specified for each entry that needs to be overriden",
|
||||||
Utils.parseConfigOptions
|
Utils.parseConfigOptions
|
||||||
)
|
)
|
||||||
.on("command:*", () => {
|
|
||||||
log.error(
|
|
||||||
`Unknown command. See ${colors.bold("--help")} for a list of available commands.`
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
})
|
|
||||||
.on("--help", Utils.extraHelp);
|
.on("--help", Utils.extraHelp);
|
||||||
|
|
||||||
// Parse options from `argv` returning `argv` void of these options.
|
// Parse options from `argv` returning `argv` void of these options.
|
||||||
|
@ -58,13 +52,9 @@ require("./outdated");
|
||||||
// a version of `argv` that does not contain options already parsed by
|
// a version of `argv` that does not contain options already parsed by
|
||||||
// `parseOptions` above.
|
// `parseOptions` above.
|
||||||
// This is done by giving it the updated `argv` that `parseOptions` returned,
|
// This is done by giving it the updated `argv` that `parseOptions` returned,
|
||||||
// except it returns an object with `args`/`unknown`, so we need to concat them.
|
// except it returns an object with `operands`/`unknown`, so we need to concat them.
|
||||||
// See https://github.com/tj/commander.js/blob/fefda77f463292/index.js#L686-L763
|
// See https://github.com/tj/commander.js/blob/fefda77f463292/index.js#L686-L763
|
||||||
program.parse(argvWithoutOptions.args.concat(argvWithoutOptions.unknown));
|
program.parse(argvWithoutOptions.operands.concat(argvWithoutOptions.unknown));
|
||||||
|
|
||||||
if (program.rawArgs.length < 3) {
|
|
||||||
program.help();
|
|
||||||
}
|
|
||||||
|
|
||||||
function createPackagesFolder() {
|
function createPackagesFolder() {
|
||||||
const packagesPath = Helper.getPackagesPath();
|
const packagesPath = Helper.getPackagesPath();
|
||||||
|
|
|
@ -8,7 +8,7 @@ const Utils = require("./utils");
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("upgrade [packages...]")
|
.command("upgrade [packages...]")
|
||||||
.description("Upgrade installed themes and packages to their latest versions.")
|
.description("Upgrade installed themes and packages to their latest versions")
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(packages) {
|
.action(function(packages) {
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
|
@ -10,7 +10,7 @@ const Utils = require("../utils");
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("edit <name>")
|
.command("edit <name>")
|
||||||
.description(`Edit user file located at ${colors.green(Helper.getUserConfigPath("<name>"))}.`)
|
.description(`Edit user file located at ${colors.green(Helper.getUserConfigPath("<name>"))}`)
|
||||||
.on("--help", Utils.extraHelp)
|
.on("--help", Utils.extraHelp)
|
||||||
.action(function(name) {
|
.action(function(name) {
|
||||||
if (!fs.existsSync(Helper.getUsersPath())) {
|
if (!fs.existsSync(Helper.getUsersPath())) {
|
||||||
|
|
|
@ -13,12 +13,10 @@ class Utils {
|
||||||
static extraHelp() {
|
static extraHelp() {
|
||||||
[
|
[
|
||||||
"",
|
"",
|
||||||
"",
|
"Environment variable:",
|
||||||
" Environment variable:",
|
` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(
|
||||||
"",
|
|
||||||
` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(
|
|
||||||
Helper.expandHome(Utils.defaultHome())
|
Helper.expandHome(Utils.defaultHome())
|
||||||
)}.`,
|
)}`,
|
||||||
"",
|
"",
|
||||||
].forEach((e) => log.raw(e));
|
].forEach((e) => log.raw(e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,9 @@ describe("Utils", function() {
|
||||||
|
|
||||||
Utils.extraHelp();
|
Utils.extraHelp();
|
||||||
|
|
||||||
// Starts with 2 empty lines
|
// Starts with 1 empty line
|
||||||
expect(stdout[0]).to.equal("\n");
|
expect(stdout[0]).to.equal("\n");
|
||||||
expect(stdout[1]).to.equal("\n");
|
expect(stdout[1]).to.not.equal("\n");
|
||||||
expect(stdout[2]).to.not.equal("\n");
|
|
||||||
|
|
||||||
// Ends with 1 empty line
|
// Ends with 1 empty line
|
||||||
expect(stdout[stdout.length - 2]).to.not.equal("\n");
|
expect(stdout[stdout.length - 2]).to.not.equal("\n");
|
||||||
|
|
Loading…
Reference in a new issue