fix(create-indiekit): handle command-line arguments - #909
Open
rmdes wants to merge 1 commit into
Open
Conversation
`create-indiekit` never read `process.argv`, so: - `--help` and `--version` fell through to the setup questions - an unrecognised option became the name of the scaffolded directory, since `base-create` takes `process.argv[2]` verbatim - a missing directory was only reported once every question had been answered, throwing those answers away - without a terminal, `prompts` never settled, so Node reported an unsettled top-level await rather than anything actionable Parse arguments with `parseArgs` from `node:util`, non-strictly so that an unrecognised option is reported by name rather than throwing, and check for an interactive terminal before asking anything. Also pass `onCancel` to `prompts`. Cancelling resolved with whatever had been answered so far, so a cancelled run carried on and scaffolded using empty answers.
rmdes
force-pushed
the
fix/create-indiekit-argv
branch
from
August 23, 2026 21:29
a6e3fb3 to
e76c45f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #908.
create-indiekitnever readprocess.argv, so--helpand--versionfell through to the setup questions, and an unrecognised option became the name of the scaffolded directory —base-createtakesprocess.argv[2]verbatim.What this changes
lib/cli.js(new) parses arguments withparseArgsfromnode:util.--help/--versionprint and exit 0; an unrecognised option is named and exits 1.base-createalready requires one, but only checks after the last answer, so those answers were thrown away.bin/create.jschecks for an interactive terminal before prompting. Without one,promptsnever settles and Node reported an unsettled top-level await; it now says what's wrong and exits 1.index.jspassesonCanceltoprompts. Cancelling resolved with whatever had been answered so far, so a cancelled run carried on and scaffolded with empty answers. It now throws, andbin/create.jsturns that into a clean exit 1.Notes on the approach
Parsed non-strictly, so an unrecognised option is reported by name rather than throwing. Under
strict: true,parseArgsthrows on anything unknown, which would turn a currently-harmless stray option into a crash.I used
parseArgsrather thancommanderto avoid adding a dependency — the package already imports fromnode:util, and this needs two booleans and one positional.packages/indiekitusescommanderfor its CLI, so say the word if you'd rather the two binaries matched and I'll switch.Cancellation is signalled with an
error.codeofERR_SETUP_CANCELLEDrather than callingprocess.exit()inindex.js, sinceunicorn/no-process-exitrestricts that to the binary.Verification
packages/create-indiekitunit tests: 23 pass, 0 fail (9 new, intest/unit/cli.js).eslintandprettierclean.No directory named
--helpis created in any of those.Not addressed here
Two inconsistencies noted in #908 that felt out of scope for this change:
engines.nodeis>=24.17while the runtime guard inbin/create.jsonly rejects Node < 20, anddocs/get-started.mddocuments the directory as optional thoughbase-createrequires it. Happy to fold either in.