File tree Expand file tree Collapse file tree
src/Illuminate/Console/Scheduling Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,13 @@ class Event
8484 */
8585 public $ output = '/dev/null ' ;
8686
87+ /**
88+ * Whether to append output to destination.
89+ *
90+ * @var bool
91+ */
92+ protected $ appendOutput = false ;
93+
8794 /**
8895 * The array of callbacks to be run before the event is started.
8996 *
@@ -204,10 +211,12 @@ protected function callAfterCallbacks(Container $container)
204211 */
205212 public function buildCommand ()
206213 {
214+ $ redirect = $ this ->appendOutput ? ' >> ' : ' > ' ;
215+
207216 if ($ this ->withoutOverlapping ) {
208- $ command = '(touch ' .$ this ->mutexPath ().'; ' .$ this ->command .'; rm ' .$ this ->mutexPath ().') > ' .$ this ->output .' 2>&1 & ' ;
217+ $ command = '(touch ' .$ this ->mutexPath ().'; ' .$ this ->command .'; rm ' .$ this ->mutexPath ().') ' . $ redirect .$ this ->output .' 2>&1 & ' ;
209218 } else {
210- $ command = $ this ->command .' > ' .$ this ->output .' 2>&1 & ' ;
219+ $ command = $ this ->command .$ redirect .$ this ->output .' 2>&1 & ' ;
211220 }
212221
213222 return $ this ->user ? 'sudo -u ' .$ this ->user .' ' .$ command : $ command ;
@@ -647,6 +656,19 @@ public function sendOutputTo($location)
647656 return $ this ;
648657 }
649658
659+ /**
660+ * Whether to append output to destination.
661+ *
662+ * @param bool $append
663+ * @return $this
664+ */
665+ public function appendOutput ($ append = true )
666+ {
667+ $ this ->appendOutput = $ append ;
668+
669+ return $ this ;
670+ }
671+
650672 /**
651673 * E-mail the results of the scheduled operation.
652674 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Console \Scheduling \Event ;
4+
5+ class EventTest extends PHPUnit_Framework_TestCase
6+ {
7+ public function testBuildCommand ()
8+ {
9+ $ event = new Event ('php -i ' );
10+
11+ $ this ->assertSame ('php -i > /dev/null 2>&1 & ' , $ event ->buildCommand ());
12+ }
13+
14+ public function testBuildCommandAppendOutput ()
15+ {
16+ $ event = new Event ('php -i ' );
17+
18+ $ event ->appendOutput ();
19+ $ this ->assertSame ('php -i >> /dev/null 2>&1 & ' , $ event ->buildCommand ());
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments