-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoboFile.php
97 lines (83 loc) · 1.99 KB
/
RoboFile.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
use Lurker\Event\FilesystemEvent;
use Symfony\Component\EventDispatcher\Event;
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks {
/**
* The source path of the app.
*/
const SOURCE_PATH = 'src/elm';
/**
* The compilation command to run.
*/
const COMPILE_CMD = 'elm make ./src/elm/Main.elm --output=../app/scripts/Main.js';
/**
* Compile the app; On success ...
*
* @param bool $optimize
* Indicate whether to optimize during compilation.
*/
private function compile_($optimize = FALSE) {
$cmd = self::COMPILE_CMD;
if ($optimize) {
// Add optimization to the command.
$cmd .= ' --optimize';
}
$result = $this->_exec($cmd);
if ($result->getExitCode() === 0) {
// Do something on success.
}
}
/**
* Compile the app (optimized).
*/
function compile() {
$this->say('Compiling (optimized).');
$this->compile_(TRUE);
}
/**
* Compile the app.
*
* Non-optimized, for `Debug.toString`.
*/
function compileDebug() {
$this->say('Compiling (non-optimized).');
$this->compile_();
}
/**
* Watch the source path and compile on change (optimized).
*/
function watch() {
$this->say('Compiling and watching (optimized).');
$this->compile_(TRUE);
$this->taskWatch()
->monitor(
self::SOURCE_PATH,
function (Event $event) {
$this->compile_(TRUE);
},
FilesystemEvent::ALL
)->run();
}
/**
* Watch the source path and compile on change.
*
* Non-optimized, for `Debug.toString`.
*/
function watchDebug() {
$this->say('Compiling and watching (non-optimized).');
$this->compile_();
$this->taskWatch()
->monitor(
self::SOURCE_PATH,
function (Event $event) {
$this->compile_();
},
FilesystemEvent::ALL
)->run();
}
}