Skip to content

Commit

Permalink
pass dir as well
Browse files Browse the repository at this point in the history
(fixing tests)
  • Loading branch information
pi0 committed Jan 13, 2025
1 parent 515db00 commit be871e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/core/dev-server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type {
NitroDevServer,
NitroWorker,
} from "nitropack/types";
import { resolve } from "pathe";
import { resolve, dirname } from "pathe";
import { debounce } from "perfect-debounce";
import { servePlaceholder } from "serve-placeholder";
import serveStatic from "serve-static";
Expand All @@ -36,7 +36,12 @@ function initWorker(filename: string): Promise<NitroWorker> | undefined {
return;
}
return new Promise((resolve, reject) => {
const worker = new Worker(filename);
const worker = new Worker(filename, {
env: {
...process.env,
NITRO_DEV_WORKER_DIR: dirname(filename),
},
});
worker.once("exit", (code) => {
reject(
new Error(
Expand Down
4 changes: 3 additions & 1 deletion src/presets/_nitro/runtime/nitro-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ function getAddress() {
if (isWindows) {
return join(String.raw`\\.\pipe\nitro`, socketName);
}
return fileURLToPath(new URL(socketName, import.meta.url));
const workerDir =
process.env.NITRO_DEV_WORKER_DIR || import.meta.dirname || process.cwd();
return join(workerDir, socketName);
}

const listenAddress = getAddress();
Expand Down

0 comments on commit be871e4

Please sign in to comment.