@@ -7,7 +7,15 @@ const scriptDir = dirname(fileURLToPath(import.meta.url));
77const packageDir = resolve ( scriptDir , ".." ) ;
88const workspaceRoot = resolve ( packageDir , "../.." ) ;
99const bundleDir = resolve ( packageDir , ".bundle" ) ;
10- const bundledNodePath = join ( bundleDir , "node" , "bin" , "node" ) ;
10+ const packageManagerExecPath = process . env . npm_execpath ;
11+ const pnpmHome = process . env . PNPM_HOME ;
12+ const pnpmExecutable = process . platform === "win32" ? "pnpm.cmd" : "pnpm" ;
13+ const bundledNodePath = join (
14+ bundleDir ,
15+ "node" ,
16+ "bin" ,
17+ process . platform === "win32" ? "node.exe" : "node" ,
18+ ) ;
1119
1220async function run ( command , args , cwd ) {
1321 await new Promise ( ( resolvePromise , rejectPromise ) => {
@@ -17,6 +25,10 @@ async function run(command, args, cwd) {
1725 stdio : "inherit" ,
1826 } ) ;
1927
28+ child . once ( "error" , ( error ) => {
29+ rejectPromise ( error ) ;
30+ } ) ;
31+
2032 child . once ( "exit" , ( code , signal ) => {
2133 if ( code === 0 ) {
2234 resolvePromise ( ) ;
@@ -32,12 +44,33 @@ async function run(command, args, cwd) {
3244 } ) ;
3345}
3446
47+ async function runPnpm ( args , cwd ) {
48+ if ( packageManagerExecPath && / \. ( c ? j s | m j s ) $ / i. test ( packageManagerExecPath ) ) {
49+ await run ( process . execPath , [ packageManagerExecPath , ...args ] , cwd ) ;
50+ return ;
51+ }
52+
53+ const packageManagerCommand = pnpmHome
54+ ? join ( pnpmHome , pnpmExecutable )
55+ : pnpmExecutable ;
56+ await run ( packageManagerCommand , args , cwd ) ;
57+ }
58+
3559await rm ( bundleDir , { force : true , recursive : true } ) ;
36- await run (
37- "pnpm" ,
38- [ "deploy" , "--legacy" , "--filter" , "@opengoat/sidecar" , "--prod" , bundleDir ] ,
60+ await runPnpm (
61+ [
62+ "deploy" ,
63+ "--legacy" ,
64+ "--filter" ,
65+ "@opengoat/sidecar" ,
66+ "--prod" ,
67+ "--config.node-linker=hoisted" ,
68+ bundleDir ,
69+ ] ,
3970 workspaceRoot ,
4071) ;
4172await mkdir ( dirname ( bundledNodePath ) , { recursive : true } ) ;
4273await cp ( process . execPath , bundledNodePath ) ;
43- await chmod ( bundledNodePath , 0o755 ) ;
74+ if ( process . platform !== "win32" ) {
75+ await chmod ( bundledNodePath , 0o755 ) ;
76+ }
0 commit comments