-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
launch depending on the installed bundler webpack/vite anoterh yarn c…
…li command
- Loading branch information
1 parent
0db1367
commit 8e3ac29
Showing
4 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Enhavo\Component\Cli\Task; | ||
|
||
use Enhavo\Component\Cli\AbstractSubroutine; | ||
use Enhavo\Component\Cli\ExecuteTrait; | ||
use Symfony\Component\Console\Command\Command; | ||
|
||
class YarnBuild extends AbstractSubroutine | ||
{ | ||
use ExecuteTrait; | ||
|
||
public function __invoke() | ||
{ | ||
while(true) { | ||
$option = $this->askYesNo($this->input, $this->output, 'vite build?', self::ANSWER_YES); | ||
|
||
if (strtolower($option) === self::ANSWER_NO) { | ||
return Command::SUCCESS; | ||
} elseif (strtolower($option) === self::ANSWER_YES) { | ||
return $this->execute(['yarn', 'build'], $this->output); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Enhavo\Component\Cli\Task; | ||
|
||
use Enhavo\Component\Cli\AbstractSubroutine; | ||
|
||
class YarnBundler extends AbstractSubroutine | ||
{ | ||
public function __invoke() | ||
{ | ||
if ($this->isVite()) { | ||
return (new YarnBuild($this->input, $this->output, $this->questionHelper))(); | ||
} | ||
|
||
return (new YarnEncore($this->input, $this->output, $this->questionHelper))(); | ||
} | ||
|
||
private function isVite(): bool | ||
{ | ||
if (getcwd() === false) { | ||
return false; | ||
} | ||
$configFile = sprintf('%s/node_modules/@vitejs', getcwd()); | ||
return file_exists($configFile); | ||
} | ||
} |