Skip to content

Replaced minimist with mri for lighter CLI args parsing #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ const debug = require("debug")("Eleventy:DevServer");

try {
const defaults = Cli.getDefaultOptions();
for(let key in defaults) {
if(key.toLowerCase() !== key) {
for (let key in defaults) {
if (key.toLowerCase() !== key) {
defaults[key.toLowerCase()] = defaults[key];
delete defaults[key];
}
}

const argv = require("minimist")(process.argv.slice(2), {
const mri = require("mri");

const argv = mri(process.argv.slice(2), {
string: [
"dir",
"input", // alias for dir
Expand All @@ -38,6 +40,9 @@ try {
"domdiff",
],
default: defaults,
alias: {
input: "dir",
},
unknown: function (unknownArgument) {
throw new Error(
`We don’t know what '${unknownArgument}' is. Use --help to see the list of supported commands.`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"debug": "^4.4.0",
"finalhandler": "^1.3.1",
"mime": "^3.0.0",
"minimist": "^1.2.8",
"morphdom": "^2.7.4",
"mri": "^1.2.0",
"please-upgrade-node": "^3.2.0",
"send": "^1.1.0",
"ssri": "^11.0.0",
Expand Down