Skip to content

Commit 114c664

Browse files
committed
✨ added auto update
1 parent b5506c8 commit 114c664

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/CreateCommand.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,21 @@ protected function skeleton3($input, $output, $directory)
153153
*/
154154
protected function execute(InputInterface $input, OutputInterface $output)
155155
{
156+
$composer = $this->findComposer();
157+
158+
$needsUpdate = \Leaf\Console\Utils\Package::updateAvailable();
159+
160+
if ($needsUpdate) {
161+
$output->writeln("<comment>Update found, updating to latest stable version...</comment>");
162+
$updateProcess = Process::fromShellCommandline("php " . dirname(__DIR__) . "/bin/leaf update");
163+
164+
$updateProcess->run();
165+
166+
if ($updateProcess->isSuccessful()) {
167+
$output->writeln("<info>Leaf CLI updated successfully, building your app...</info>");
168+
}
169+
}
170+
156171
$name = $input->getArgument('project-name');
157172

158173
$directory = $name !== '.' ? getcwd() . '/' . $name : getcwd();
@@ -173,8 +188,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
173188
return $this->skeleton3($input, $output, $directory);
174189
}
175190

176-
$composer = $this->findComposer();
177-
178191
$commands = [
179192
$composer . " create-project leafs/$preset " . basename($directory)
180193
];

0 commit comments

Comments
 (0)