@@ -30,8 +30,10 @@ public function __construct($config = array()) {
30
30
31
31
/**
32
32
* Watch the source/ directory for any changes to existing files. Will run forever if given the chance.
33
+ * @param {Boolean} decide if the reload server should be turned on
34
+ * @param {Boolean} decide if static files like CSS and JS should be moved
33
35
*/
34
- public function watch ($ reload = false ) {
36
+ public function watch ($ reload = false , $ moveStatic = true ) {
35
37
36
38
// automatically start the auto-refresh tool
37
39
if ($ reload ) {
@@ -155,55 +157,60 @@ public function watch($reload = false) {
155
157
}
156
158
157
159
// iterate over all of the other files in the source directory and move them if their modified time has changed
158
- $ objects = new \RecursiveIteratorIterator (new \RecursiveDirectoryIterator ($ this ->sd ."/ " ), \RecursiveIteratorIterator::SELF_FIRST );
159
-
160
- // make sure dots are skipped
161
- $ objects ->setFlags (\FilesystemIterator::SKIP_DOTS );
162
-
163
- foreach ($ objects as $ name => $ object ) {
160
+ if ($ moveStatic ) {
164
161
165
- // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
166
- $ fileName = str_replace ($ this ->sd .DIRECTORY_SEPARATOR ,"" ,$ name );
167
- if (($ fileName [0 ] != "_ " ) && (!in_array ($ object ->getExtension (),$ this ->ie )) && (!in_array ($ object ->getFilename (),$ this ->id ))) {
168
-
169
- // catch directories that have the ignored dir in their path
170
- $ ignoreDir = $ this ->ignoreDir ($ fileName );
171
-
172
- // check to see if it's a new directory
173
- if (!$ ignoreDir && $ object ->isDir () && !isset ($ o ->$ fileName ) && !is_dir ($ this ->pd ."/ " .$ fileName )) {
174
- mkdir ($ this ->pd ."/ " .$ fileName );
175
- $ o ->$ fileName = "dir created " ; // placeholder
176
- print $ fileName ."/ directory was created... \n" ;
177
- }
162
+ $ objects = new \RecursiveIteratorIterator (new \RecursiveDirectoryIterator ($ this ->sd ."/ " ), \RecursiveIteratorIterator::SELF_FIRST );
163
+
164
+ // make sure dots are skipped
165
+ $ objects ->setFlags (\FilesystemIterator::SKIP_DOTS );
166
+
167
+ foreach ($ objects as $ name => $ object ) {
178
168
179
- // check to see if it's a new file or a file that has changed
180
- if (file_exists ($ name )) {
169
+ // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
170
+ $ fileName = str_replace ($ this ->sd .DIRECTORY_SEPARATOR ,"" ,$ name );
171
+ if (($ fileName [0 ] != "_ " ) && (!in_array ($ object ->getExtension (),$ this ->ie )) && (!in_array ($ object ->getFilename (),$ this ->id ))) {
181
172
182
- $ mt = $ object ->getMTime ();
183
- if (!$ ignoreDir && $ object ->isFile () && !isset ($ o ->$ fileName ) && !file_exists ($ this ->pd ."/ " .$ fileName )) {
184
- $ o ->$ fileName = $ mt ;
185
- $ this ->moveStaticFile ($ fileName ,"added " );
186
- if ($ object ->getExtension () == "css " ) {
187
- $ this ->updateSite ($ fileName ,"changed " ,0 ); // make sure the site is updated for MQ reasons
188
- }
189
- } else if (!$ ignoreDir && $ object ->isFile () && isset ($ o ->$ fileName ) && ($ o ->$ fileName != $ mt )) {
190
- $ o ->$ fileName = $ mt ;
191
- $ this ->moveStaticFile ($ fileName ,"changed " );
192
- if ($ object ->getExtension () == "css " ) {
193
- $ this ->updateSite ($ fileName ,"changed " ,0 ); // make sure the site is updated for MQ reasons
173
+ // catch directories that have the ignored dir in their path
174
+ $ ignoreDir = $ this ->ignoreDir ($ fileName );
175
+
176
+ // check to see if it's a new directory
177
+ if (!$ ignoreDir && $ object ->isDir () && !isset ($ o ->$ fileName ) && !is_dir ($ this ->pd ."/ " .$ fileName )) {
178
+ mkdir ($ this ->pd ."/ " .$ fileName );
179
+ $ o ->$ fileName = "dir created " ; // placeholder
180
+ print $ fileName ."/ directory was created... \n" ;
181
+ }
182
+
183
+ // check to see if it's a new file or a file that has changed
184
+ if (file_exists ($ name )) {
185
+
186
+ $ mt = $ object ->getMTime ();
187
+ if (!$ ignoreDir && $ object ->isFile () && !isset ($ o ->$ fileName ) && !file_exists ($ this ->pd ."/ " .$ fileName )) {
188
+ $ o ->$ fileName = $ mt ;
189
+ $ this ->moveStaticFile ($ fileName ,"added " );
190
+ if ($ object ->getExtension () == "css " ) {
191
+ $ this ->updateSite ($ fileName ,"changed " ,0 ); // make sure the site is updated for MQ reasons
192
+ }
193
+ } else if (!$ ignoreDir && $ object ->isFile () && isset ($ o ->$ fileName ) && ($ o ->$ fileName != $ mt )) {
194
+ $ o ->$ fileName = $ mt ;
195
+ $ this ->moveStaticFile ($ fileName ,"changed " );
196
+ if ($ object ->getExtension () == "css " ) {
197
+ $ this ->updateSite ($ fileName ,"changed " ,0 ); // make sure the site is updated for MQ reasons
198
+ }
199
+ } else if (!isset ($ o ->fileName )) {
200
+ $ o ->$ fileName = $ mt ;
194
201
}
195
- } else if (!isset ($ o ->fileName )) {
196
- $ o ->$ fileName = $ mt ;
202
+
203
+ } else {
204
+ unset($ o ->$ fileName );
197
205
}
198
206
199
- } else {
200
- unset($ o ->$ fileName );
201
207
}
202
208
203
209
}
204
210
205
211
}
206
212
213
+
207
214
$ c = true ;
208
215
209
216
// taking out the garbage. basically killing mustache after each run.
0 commit comments