-
Notifications
You must be signed in to change notification settings - Fork 0
/
ThemeWatchCommand.php
38 lines (31 loc) · 1.08 KB
/
ThemeWatchCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Fire\Robo\Plugin\Commands;
use Robo\Symfony\ConsoleIO;
use Fire\Robo\Plugin\Commands\FireCommandBase;
use Robo\Robo;
/**
* Provides a command to watch the custom theme.
*/
class ThemeWatchCommand extends FireCommandBase {
/**
* Builds Projects theme.
*
* Usage Example: fire theme-watch
*
* @command local:theme:watch
* @aliases theme-watch, watch-theme, tw
*
*/
public function themeWatch(ConsoleIO $io) {
$root = $this->getThemePath();
$npmCommand = Robo::config()->get('local_theme_watch_script') ?: '';
$command = 'cd ' . $root . ' && npm run ' . $npmCommand;
if (empty($npmCommand)) {
$io->say('You have not configured any command for "theme watch" please add the variable "local_theme_watch_script" to your fire.yml (or fire.local.yml) configuration file.');
}
elseif (file_exists($root . '/.nvmrc') && getenv('NVM_DIR')) {
$command = 'export NVM_DIR=$HOME/.nvm && . $NVM_DIR/nvm.sh && cd ' . $root . ' && nvm install && npm ci && npm run ' . $npmCommand;
}
$this->taskExec($command)->run();
}
}