Skip to content

Commit 7f49f65

Browse files
committed
feat: inject pnpm binary shims into build PATH for improved execution support
1 parent b346a0f commit 7f49f65

5 files changed

Lines changed: 42 additions & 4 deletions

File tree

.changeset/pre.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"tall-pens-wait",
6464
"tasty-cities-drum",
6565
"tasty-meteors-shout",
66+
"ten-ties-brush",
6667
"true-carpets-lead",
6768
"twenty-falcons-swim",
6869
"yummy-streets-tie"

.changeset/ten-ties-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pipelab/plugin-electron": patch
3+
---
4+
5+
fix pnpm shimming

plugins/plugin-electron/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @pipelab/plugin-electron
22

3+
## 1.0.0-beta.33
4+
5+
### Patch Changes
6+
7+
- fix pnpm shimming
8+
39
## 1.0.0-beta.32
410

511
### Patch Changes

plugins/plugin-electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipelab/plugin-electron",
3-
"version": "1.0.0-beta.32",
3+
"version": "1.0.0-beta.33",
44
"description": "Pipelab plugin for packaging apps with Electron",
55
"keywords": [
66
"automation",

plugins/plugin-electron/src/forge.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from "@pipelab/plugin-core";
1818

1919
import { dirname, join, basename, delimiter } from "node:path";
20-
import { cp, readFile, writeFile, rm } from "node:fs/promises";
20+
import { cp, readFile, writeFile, rm, mkdir } from "node:fs/promises";
2121
import { existsSync } from "node:fs";
2222
import { platform as osPlatform, arch as osArch } from "node:os";
2323
import { kebabCase } from "change-case";
@@ -570,6 +570,25 @@ export const forge = async (
570570
log(`Staging build in ${destinationFolder}`);
571571

572572
try {
573+
const shimDir = join(destinationFolder, ".bin");
574+
await mkdir(shimDir, { recursive: true });
575+
576+
const pnpmCjsPath = paths.pnpm;
577+
578+
// Write pnpm.cmd for Windows support
579+
await writeFile(
580+
join(shimDir, "pnpm.cmd"),
581+
`@echo off\r\n"${node}" "${pnpmCjsPath}" %*\r\n`,
582+
"utf8",
583+
);
584+
585+
// Write pnpm shell script for Unix/Linux/macOS support
586+
await writeFile(
587+
join(shimDir, "pnpm"),
588+
`#!/bin/sh\nexec "${node}" "${pnpmCjsPath}" "$@"\n`,
589+
{ encoding: "utf8", mode: 0o755 },
590+
);
591+
573592
const forge = join(
574593
destinationFolder,
575594
"node_modules",
@@ -786,7 +805,7 @@ export const forge = async (
786805
env: {
787806
DEBUG: completeConfiguration.enableExtraLogging ? "*" : "",
788807
ELECTRON_NO_ASAR: "1",
789-
PATH: `${dirname(node)}${delimiter}${process.env.PATH}`,
808+
PATH: `${shimDir}${delimiter}${dirname(node)}${delimiter}${process.env.PATH}`,
790809
// DEBUG: "electron-packager"
791810
},
792811
cancelSignal: abortSignal,
@@ -853,6 +872,13 @@ export const forge = async (
853872
e instanceof Error ? `${e.message}\n${e.stack}` : String(e),
854873
);
855874
}
856-
await rm(destinationFolder, { recursive: true, force: true });
875+
try {
876+
await rm(destinationFolder, { recursive: true, force: true });
877+
} catch (e) {
878+
log(
879+
"Failed to clean up staging directory:",
880+
e instanceof Error ? `${e.message}\n${e.stack}` : String(e),
881+
);
882+
}
857883
}
858884
};

0 commit comments

Comments
 (0)