Skip to content

Commit e9dc869

Browse files
committed
fix: enhance package manager resolution for pnpm in installation process
1 parent 6f24eb1 commit e9dc869

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

adminforth/commands/createApp/utils.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,27 @@ 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+
}
505+
}
506+
}
507+
490508
async function installDependencies(ctx, cwd, packageManager) {
491-
const command = `${packageManager} install`;
509+
const packageManagerCommand = await resolvePackageManagerCommand(packageManager);
510+
const command = `${packageManagerCommand} install`;
492511

493512
await Promise.all([
494513
execAsync(command, { cwd, env: process.env }),

0 commit comments

Comments
 (0)