From 6065c1ebf306889031bbea95c43d8497df014ca7 Mon Sep 17 00:00:00 2001 From: Katja Lutz Date: Tue, 28 Jun 2022 16:58:51 +0200 Subject: [PATCH] fix: use proper cwd in rappli binary --- bin/rappli.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/rappli.js b/bin/rappli.js index 20813b0..91d6306 100755 --- a/bin/rappli.js +++ b/bin/rappli.js @@ -1,13 +1,20 @@ #!/usr/bin/env node import { exec } from "node:child_process"; -const process = exec("npm run start", (error, stdout, stderr) => { - if (error) { - console.error(`${error}`); - return; +import { resolve } from "node:path"; +import { fileURLToPath } from "url"; + +const process = exec( + "npm run start", + { cwd: resolve(fileURLToPath(import.meta.url), "..") }, + (error, stdout, stderr) => { + if (error) { + console.error(`${error}`); + return; + } + console.log(`${stdout}`); + console.error(`${stderr}`); } - console.log(`${stdout}`); - console.error(`${stderr}`); -}); +); process.stdout.on("data", (data) => console.log(data)); process.stderr.on("data", (data) => console.error(data));