Skip to content

Commit

Permalink
Switch to static functions for Eleventy version and help args. Fixes #…
Browse files Browse the repository at this point in the history
…1313

(cherry picked from commit 2b18aab)
  • Loading branch information
zachleat committed Apr 15, 2022
1 parent e25a7d2 commit 6b3db05
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
24 changes: 12 additions & 12 deletions cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ try {
);
});

let elev = new Eleventy(argv.input, argv.output, {
// --quiet and --quiet=true both resolve to true
quietMode: argv.quiet,
configPath: argv.config,
source: "cli",
});

// reuse ErrorHandler instance in Eleventy
errorHandler = elev.errorHandler;

if (argv.version) {
console.log(elev.getVersion());
console.log(Eleventy.getVersion());
} else if (argv.help) {
console.log(elev.getHelp());
console.log(Eleventy.getHelp());
} else {
let elev = new Eleventy(argv.input, argv.output, {
// --quiet and --quiet=true both resolve to true
quietMode: argv.quiet,
configPath: argv.config,
source: "cli",
});

// reuse ErrorHandler instance in Eleventy
errorHandler = elev.errorHandler;

if (argv.to === "json" || argv.to === "ndjson") {
// override logging output
elev.setIsVerbose(false);
Expand Down
22 changes: 18 additions & 4 deletions src/Eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,20 +527,27 @@ Verbose Output: ${this.verboseMode}`);
/**
* Reads the version of Eleventy.
*
* @method
* @static
* @returns {String} - The version of Eleventy.
*/
getVersion() {
static getVersion() {
return pkg.version;
}

/**
* @deprecated since 1.0.1, use static Eleventy.getVersion()
*/
getVersion() {
return Eleventy.getVersion();
}

/**
* Shows a help message including usage.
*
* @method
* @static
* @returns {String} - The help mesage.
*/
getHelp() {
static getHelp() {
return `Usage: eleventy
eleventy --input=. --output=./_site
eleventy --serve
Expand Down Expand Up @@ -586,6 +593,13 @@ Arguments:
--help`;
}

/**
* @deprecated since 1.0.1, use static Eleventy.getHelp()
*/
getHelp() {
return Eleventy.getHelp();
}

/**
* Resets the config of Eleventy.
*
Expand Down

0 comments on commit 6b3db05

Please sign in to comment.