@@ -487,32 +487,42 @@ async function writeTemplateFiles(dirname, cwd, useNpm, includePrismaMigrations,
487487 }
488488}
489489
490- async function resolvePackageManagerCommand ( packageManager ) {
491- if ( packageManager !== 'pnpm' ) {
492- return packageManager ;
493- }
494-
495- try {
496- await execAsync ( 'pnpm --version' , { env : process . env } ) ;
497- return 'pnpm' ;
498- } catch {
499- try {
500- await execAsync ( 'corepack pnpm --version' , { env : process . env } ) ;
501- return 'corepack pnpm' ;
502- } catch {
503- throw new Error ( 'pnpm is not available. Install pnpm globally or enable Corepack before creating a pnpm project.' ) ;
504- }
490+ async function installDependenciesPnpm ( ctx , cwd ) {
491+ const isWindows = process . platform === 'win32' ;
492+
493+ const nodeBinary = process . execPath ;
494+ const pnpmPath = path . join ( path . dirname ( nodeBinary ) , isWindows ? 'pnpm.cmd' : 'pnpm' ) ;
495+ const customDir = ctx . customDir ;
496+ if ( isWindows ) {
497+ const res = await Promise . all ( [
498+ execAsync ( `pnpm install` , { cwd, env : { PATH : process . env . PATH } } ) ,
499+ execAsync ( `pnpm install` , { cwd : customDir , env : { PATH : process . env . PATH } } ) ,
500+ ] ) ;
501+ } else {
502+ const res = await Promise . all ( [
503+ execAsync ( `${ nodeBinary } ${ pnpmPath } install` , { cwd, env : { PATH : process . env . PATH } } ) ,
504+ execAsync ( `${ nodeBinary } ${ pnpmPath } install` , { cwd : customDir , env : { PATH : process . env . PATH } } ) ,
505+ ] ) ;
505506 }
506507}
507508
508- async function installDependencies ( ctx , cwd , packageManager ) {
509- const packageManagerCommand = await resolvePackageManagerCommand ( packageManager ) ;
510- const command = `${ packageManagerCommand } install` ;
511-
512- await Promise . all ( [
513- execAsync ( command , { cwd, env : process . env } ) ,
514- execAsync ( command , { cwd : ctx . customDir , env : process . env } ) ,
515- ] ) ;
509+ async function installDependenciesNpm ( ctx , cwd ) {
510+ const isWindows = process . platform === 'win32' ;
511+
512+ const nodeBinary = process . execPath ;
513+ const npmPath = path . join ( path . dirname ( nodeBinary ) , isWindows ? 'npm.cmd' : 'npm' ) ;
514+ const customDir = ctx . customDir ;
515+ if ( isWindows ) {
516+ const res = await Promise . all ( [
517+ execAsync ( `npm install` , { cwd, env : { PATH : process . env . PATH } } ) ,
518+ execAsync ( `npm install` , { cwd : customDir , env : { PATH : process . env . PATH } } ) ,
519+ ] ) ;
520+ } else {
521+ const res = await Promise . all ( [
522+ execAsync ( `${ nodeBinary } ${ npmPath } install` , { cwd, env : { PATH : process . env . PATH } } ) ,
523+ execAsync ( `${ nodeBinary } ${ npmPath } install` , { cwd : customDir , env : { PATH : process . env . PATH } } ) ,
524+ ] ) ;
525+ }
516526}
517527
518528function generateFinalInstructionsPnpm ( skipPrismaSetup , options ) {
@@ -586,7 +596,11 @@ export function prepareWorkflow(options) {
586596 {
587597 title : '📦 Installing dependencies...' ,
588598 task : async ( ctx ) => {
589- await installDependencies ( ctx , ctx . projectDir , options . useNpm ? 'npm' : 'pnpm' ) ;
599+ if ( options . useNpm ) {
600+ await installDependenciesNpm ( ctx , ctx . projectDir ) ;
601+ } else {
602+ await installDependenciesPnpm ( ctx , ctx . projectDir ) ;
603+ }
590604 }
591605 } ,
592606 {
0 commit comments