Skip to content
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

fix: when no operation command, execute the dev in the remix cli #9420

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
40 changes: 40 additions & 0 deletions packages/remix-dev/__tests__/cli-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import util from "node:util";
import fse from "fs-extra";
import semver from "semver";

import { run } from "../cli/run";

let execFile = util.promisify(childProcess.execFile);

const TEMP_DIR = path.join(
Expand All @@ -22,6 +24,16 @@ afterAll(async () => {
await fse.remove(TEMP_DIR);
});

jest.mock("../cli/commands", () => {
let originalModule = jest.requireActual("../cli/commands");

return {
__esModule: true,
...originalModule,
dev: jest.fn(),
};
});

async function execRemix(
args: Array<string>,
options: Exclude<Parameters<typeof execFile>[2], null | undefined> = {}
Expand Down Expand Up @@ -199,4 +211,32 @@ describe("remix CLI", () => {
expect(!!semver.valid(stdout.trim())).toBe(true);
});
});

describe("the `dev` command", () => {
beforeEach(() => {
let remixRoot = path.join(__dirname, "fixtures", "node");

fse.copySync(remixRoot, TEMP_DIR);
});

it("call the `dev` command process", async () => {
let res = await run(["dev"]);

expect(res).toBeUndefined();
});
});

describe("not command specified", () => {
beforeEach(() => {
let remixRoot = path.join(__dirname, "fixtures", "node");

fse.copySync(remixRoot, TEMP_DIR);
});

it("call the `dev` command process", async () => {
let res = await run([]);

expect(res).toBeUndefined();
});
});
});
4 changes: 2 additions & 2 deletions packages/remix-dev/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export async function run(argv: string[] = process.argv.slice(2)) {
"--tls-key": String,
"--tls-cert": String,

...(argv[0].startsWith("vite:") ||
...(argv[0]?.startsWith("vite:") ||
argv[0] === "reveal" ||
argv[0] === "routes"
? // Handle commands that support Vite's --config flag
Expand All @@ -176,7 +176,7 @@ export async function run(argv: string[] = process.argv.slice(2)) {
"-c": "--command",
}),

...(argv[0].startsWith("vite:")
...(argv[0]?.startsWith("vite:")
? {
// Vite commands
// --config, --force and --port are already defined above
Expand Down