Skip to content

Commit 19b7682

Browse files
committed
added build() so other functions could call watch. added --noprocs so no processes can be spawned.
1 parent 944efca commit 19b7682

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/PatternLab/Console/Commands/WatchCommand.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use \PatternLab\Config;
1414
use \PatternLab\Console;
1515
use \PatternLab\Console\Command;
16+
use \PatternLab\Console\ProcessSpawner;
1617
use \PatternLab\Generator;
1718
use \PatternLab\Timer;
1819
use \PatternLab\Watcher;
@@ -29,6 +30,7 @@ public function __construct() {
2930
Console::setCommandOption($this->command,"patternsonly","Watches only the patterns. Does NOT clean <path>public/</path>.","To watch and generate only the patterns:","p");
3031
Console::setCommandOption($this->command,"nocache","Set the cacheBuster value to 0.","To watch and turn off the cache buster:","n");
3132
Console::setCommandOption($this->command,"sk","Watch for changes to the StarterKit and copy to <path>source/</path>. The <info>--sk</info> flag should only be used if one is actively developing a StarterKit.","To watch for changes to the StarterKit:");
33+
Console::setCommandOption($this->command,"noprocs","Disable plug-in related processes. For use with <info>--server --with-watch</info>.","To disable plug-in related processes:");
3234
Console::setCommandSample($this->command,"To watch only patterns and turn off the cache buster:","--patternsonly --nocache");
3335
//Console::setCommandOption($this->command,"autoreload","Turn on the auto-reload service.","To turn on auto-reload:","r");
3436

@@ -53,6 +55,12 @@ public function run() {
5355

5456
} else {
5557

58+
// collect any processes that might be related to watch (e.g. reload). spawn them.
59+
if (!Console::findCommandOption("noprocs")) {
60+
$process = new ProcessSpawner;
61+
$process->run();
62+
}
63+
5664
// load the generator
5765
$g = new Generator();
5866
$g->generate($options);
@@ -63,6 +71,20 @@ public function run() {
6371

6472
}
6573

74+
}
75+
76+
public function build() {
77+
78+
$command = $this->pathPHP." ".$this->pathConsole." --".$this->command;
79+
80+
if (Console::findCommandOption("p|patternsonly")) {
81+
$command .= " --patternsonly";
82+
}
83+
if (Console::findCommandOption("n|nocache")) {
84+
$command .= " --nocache";
85+
}
86+
87+
return $command;
6688

6789
}
6890

0 commit comments

Comments
 (0)