Skip to content

Commit db5db7c

Browse files
authored
Support pnpm and yarn package managers (#433)
* support pnpm and yarn package managers * styleci
1 parent 2b73305 commit db5db7c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/NewCommand.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,23 +310,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int
310310
$output->writeln('');
311311
}
312312

313+
$packageInstall = 'npm install';
314+
315+
if (file_exists($directory.'/pnpm-lock.yaml')) {
316+
$packageInstall = 'pnpm install';
317+
} elseif (file_exists($directory.'/yarn.lock')) {
318+
$packageInstall = 'yarn install';
319+
}
320+
313321
$runNpm = $input->getOption('npm');
314322

315323
if (! $input->getOption('npm') && $input->isInteractive()) {
316324
$runNpm = confirm(
317-
label: 'Would you like to run <options=bold>npm install</> and <options=bold>npm run build</>?'
325+
label: 'Would you like to run <options=bold>'.$packageInstall.'</> and <options=bold>npm run build</>?'
318326
);
319327
}
320328

321329
if ($runNpm) {
322-
$this->runCommands(['npm install', 'npm run build'], $input, $output, workingPath: $directory);
330+
$this->runCommands([$packageInstall, 'npm run build'], $input, $output, workingPath: $directory);
323331
}
324332

325333
$output->writeln(" <bg=blue;fg=white> INFO </> Application ready in <options=bold>[{$name}]</>. You can start your local development using:".PHP_EOL);
326334
$output->writeln('<fg=gray>➜</> <options=bold>cd '.$name.'</>');
327335

328336
if (! $runNpm) {
329-
$output->writeln('<fg=gray>➜</> <options=bold>npm install && npm run build</>');
337+
$output->writeln('<fg=gray>➜</> <options=bold>'.$packageInstall.' && npm run build</>');
330338
}
331339

332340
if ($this->isParkedOnHerdOrValet($directory)) {

0 commit comments

Comments
 (0)