Skip to content

Commit 969c999

Browse files
committed
feat: enhance CliTest command to check for outdated packages and handle npm install results
1 parent 566f7af commit 969c999

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Console/Command/CliTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace OpenForgeProject\MageForge\Console\Command;
66

7+
use Dotenv\Regex\Success;
78
use Laravel\Prompts\MultiSelectPrompt;
89
use OpenForgeProject\MageForge\Model\ThemeList;
910
use OpenForgeProject\MageForge\Model\ThemePath;
@@ -38,10 +39,37 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3839

3940
$output->writeln('Running npm outdated...');
4041
exec('npm outdated', $npmOutput, $returnValue);
42+
43+
if ($returnValue !== 0 || !empty($npmOutput)) {
44+
$io = new SymfonyStyle($input, $output);
45+
$io->warning('Outdated packages found!');
46+
} else {
47+
$io = new SymfonyStyle($input, $output);
48+
$io->success('No outdated packages found, proceeding with installation.');
49+
}
50+
4151
foreach ($npmOutput as $line) {
4252
$output->writeln($line);
4353
}
4454

55+
56+
57+
sleep(2);
58+
59+
$output->writeln('Running npm install...');
60+
exec('npm install', $npmOutput, $returnValue);
61+
foreach ($npmOutput as $line) {
62+
$output->writeln($line);
63+
}
64+
65+
if ($returnValue !== 0) {
66+
$io = new SymfonyStyle($input, $output);
67+
$io->error('Npm install failed!');
68+
return Command::FAILURE;
69+
}
70+
71+
$io->success('Npm install completed successfully.');
72+
4573
return Command::SUCCESS;
4674
}
4775

0 commit comments

Comments
 (0)