Skip to content
Open
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
20 changes: 15 additions & 5 deletions cmd.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ try {
}
}

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
Copy link
Author

@outslept outslept Jul 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: perhaps the comment should be phrased differently as it is not an alias, but a fallback to dir

Expand All @@ -38,12 +39,21 @@ try {
"domdiff",
],
default: defaults,
unknown: function (unknownArgument) {
});

// Manual unknown argument validation for minimist compatibility
// mri doesn't provide the same unknown flag detection, so we replicate it
const knownFlags = [
"dir", "input", "port", "version", "help", "domdiff"
];

for (const key of Object.keys(argv)) {
if (key !== '_' && !knownFlags.includes(key)) {
throw new Error(
`We dont know what '${unknownArgument}' is. Use --help to see the list of supported commands.`
`We don't know what '${key}' is. Use --help to see the list of supported commands.`
);
},
});
}
}

debug("command: eleventy-dev-server %o", argv);

Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"debug": "^4.4.1",
"finalhandler": "^2.1.0",
"mime": "^4.0.7",
"minimist": "^1.2.8",
"morphdom": "^2.7.5",
"mri": "^1.2.0",
"please-upgrade-node": "^3.2.0",
"send": "^1.2.0",
"ssri": "^12.0.0",
Expand Down