From ca477c86af38f08c3b9a34147e9145f6a4e84677 Mon Sep 17 00:00:00 2001 From: Liam Cooper Date: Wed, 14 Jun 2023 14:26:16 +0100 Subject: [PATCH] feat(medusa): Preserve node flags in develop command (#1860) --- .changeset/five-gorillas-sit.md | 5 +++++ packages/medusa/src/commands/develop.js | 28 +++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 .changeset/five-gorillas-sit.md diff --git a/.changeset/five-gorillas-sit.md b/.changeset/five-gorillas-sit.md new file mode 100644 index 0000000000..8a436207db --- /dev/null +++ b/.changeset/five-gorillas-sit.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +feat(medusa): Preserve node flags in develop command diff --git a/packages/medusa/src/commands/develop.js b/packages/medusa/src/commands/develop.js index d255bd2d74..12144c9c72 100644 --- a/packages/medusa/src/commands/develop.js +++ b/packages/medusa/src/commands/develop.js @@ -1,7 +1,7 @@ +import path from "path" +import { fork, execSync } from "child_process" import boxen from "boxen" -import { execSync } from "child_process" import chokidar from "chokidar" -import spawn from "cross-spawn" import Store from "medusa-telemetry/dist/store" import { EOL } from "os" import path from "path" @@ -46,12 +46,17 @@ export default async function ({ port, directory }) { stdio: ["ignore", process.stdout, process.stderr], }) - const cliPath = path.join(directory, "node_modules", ".bin", "medusa") - let child = spawn(cliPath, [`start`, ...args], { - cwd: directory, - env: process.env, - stdio: ["pipe", process.stdout, process.stderr], - }) + const cliPath = path.join( + directory, + "node_modules", + "@medusajs", + "medusa", + "dist", + "bin", + "medusa.js" + ) + let child = fork(cliPath, [`start`, ...args], { cwd: directory }) + child.on("error", function (err) { console.log("Error ", err) process.exit(1) @@ -74,11 +79,8 @@ export default async function ({ port, directory }) { Logger.info("Rebuilt") - child = spawn(cliPath, [`start`, ...args], { - cwd: directory, - env: process.env, - stdio: ["pipe", process.stdout, process.stderr], - }) + child = fork(cliPath, [`start`, ...args], { cwd: directory }) + child.on("error", function (err) { console.log("Error ", err) process.exit(1)