Skip to content

Commit

Permalink
chore: fix recursive pnpm on node 18.18 (#8994)
Browse files Browse the repository at this point in the history
* chore: fix recursive pnpm on node 18.18

* maybe

* fix prod
  • Loading branch information
runspired authored Oct 11, 2023
1 parent eeaf234 commit c05f98a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
16 changes: 15 additions & 1 deletion packages/holodeck/bin/cmd/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
const isBun = typeof Bun !== 'undefined';
const { process } = globalThis;
import { spawn } from './spawn.js';
import fs from 'fs';

export default async function run(args) {
const pkg = JSON.parse(fs.readFileSync('./package.json'), 'utf8');
const cmd = args[0];
const isPkgScript = pkg.scripts[cmd];

if (isBun) {
await spawn(['bun', 'run', 'holodeck:start-program']);

Expand All @@ -24,7 +29,16 @@ export default async function run(args) {

let exitCode = 0;
try {
await spawn(['pnpm', 'exec', ...args]);
if (isPkgScript) {
const cmdArgs = pkg.scripts[cmd].split(' ');
if (args.length > 1) {
cmdArgs.push(...args.slice(1));
}
console.log({ cmdArgs });
await spawn(cmdArgs);
} else {
await spawn(['pnpm', 'exec', ...args]);
}
} catch (e) {
exitCode = e;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/holodeck/bin/cmd/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const isBun = typeof Bun !== 'undefined';
export async function spawn(args, options) {
if (isBun) {
const proc = Bun.spawn(args, {
env: process.env,
cwd: process.cwd(),
stdout: 'inherit',
stderr: 'inherit',
});
Expand Down Expand Up @@ -33,5 +35,6 @@ export async function spawn(args, options) {

await pSpawn(args.shift(), args, {
stdio: 'inherit',
shell: true,
});
}
4 changes: 2 additions & 2 deletions tests/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"holodeck:start-program": "holodeck start",
"holodeck:end-program": "holodeck end",
"launch:tests": "ember test --port=0 --serve --no-launch",
"start": "holodeck run pnpm launch:tests",
"test": "holodeck run pnpm examine"
"start": "holodeck run launch:tests",
"test": "holodeck run examine"
},
"author": "",
"license": "MIT",
Expand Down

0 comments on commit c05f98a

Please sign in to comment.