Skip to content

Commit

Permalink
Fix CLI arg parsing to allow usage with no arguments (#12925)
Browse files Browse the repository at this point in the history
brophdawg11 authored Jan 31, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent fa00680 commit 570658c
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-olives-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-router/dev": patch
---

Fix CLI parsing to allow argumentless `npx react-router` usage
4 changes: 2 additions & 2 deletions packages/react-router-dev/bin.js
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ let arg = require("arg");
// default `NODE_ENV` so React loads the proper version in it's CJS entry script.
// We have to do this before importing `run.ts` since that is what imports
// `react` (indirectly via `react-router`)
let args = arg({}, { argv: process.argv.slice(2), stopAtPositional: true });
if (args._[0] === "dev") {
let args = arg({}, { argv: process.argv.slice(2), permissive: true });
if (args._.length === 0 || args._[0] === "dev") {
process.env.NODE_ENV = process.env.NODE_ENV ?? "development";
} else {
process.env.NODE_ENV = process.env.NODE_ENV ?? "production";

0 comments on commit 570658c

Please sign in to comment.