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
23 changes: 17 additions & 6 deletions cmd.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require("please-upgrade-node")(pkg, {
},
});

const minimist = require("minimist");
const mri = require("mri");
const debug = require("debug")("Eleventy:cmd");

class SimpleError extends Error {
Expand All @@ -31,7 +31,7 @@ async function exec() {
const { EleventyErrorHandler } = await import("./src/Errors/EleventyErrorHandler.js");

try {
const argv = minimist(process.argv.slice(2), {
const argv = mri(process.argv.slice(2), {
string: ["input", "output", "formats", "config", "pathprefix", "port", "to", "incremental", "loader"],
boolean: [
"quiet",
Expand All @@ -47,12 +47,23 @@ async function exec() {
"ignore-initial": false,
"to": "fs",
},
unknown: function (unknownArgument) {
});

// mri doesn't provide the same unknown flag detection as minimist,
// so we implement it manually for better UX
const knownFlags = [
"input", "output", "formats", "config", "pathprefix", "port", "to",
"incremental", "loader", "quiet", "version", "watch", "dryrun",
"help", "serve", "ignore-initial"
];

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 %o", argv);
const { Eleventy } = await import("./src/Eleventy.js");
Expand Down
71 changes: 50 additions & 21 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 @@ -153,8 +153,8 @@
"kleur": "^4.1.5",
"liquidjs": "^10.21.1",
"markdown-it": "^14.1.0",
"minimist": "^1.2.8",
"moo": "^0.5.2",
"mri": "^1.2.0",
"node-retrieve-globals": "^6.0.1",
"nunjucks": "^3.2.4",
"picomatch": "^4.0.3",
Expand Down