@@ -214,7 +214,12 @@ protected function generateMainPages() {
214214 $ styleGuideHead = $ this ->mv ->render ($ this ->mainPageHead ,$ sd );
215215 $ styleGuideFoot = $ this ->mv ->render ($ this ->mainPageFoot ,$ sd );
216216 $ styleGuidePage = $ styleGuideHead .$ this ->mfs ->render ('viewall ' ,$ sd ).$ styleGuideFoot ;
217- file_put_contents ($ this ->pd ."/styleguide/html/styleguide.html " ,$ styleGuidePage );
217+
218+ if (!file_exists ($ this ->pd ."/styleguide/html/styleguide.html " )) {
219+ print "ERROR: the main style guide wasn't written out. make sure public/styleguide exists. can copy core/styleguide \n" ;
220+ } else {
221+ file_put_contents ($ this ->pd ."/styleguide/html/styleguide.html " ,$ styleGuidePage );
222+ }
218223
219224 }
220225
@@ -223,6 +228,11 @@ protected function generateMainPages() {
223228 */
224229 protected function generatePatterns () {
225230
231+ // make sure patterns exists
232+ if (!is_dir ($ this ->pd ."/patterns " )) {
233+ mkdir ($ this ->pd ."/patterns " );
234+ }
235+
226236 // make sure the pattern header & footer are added
227237 $ this ->addPatternHF = true ;
228238
@@ -1172,21 +1182,25 @@ protected function updateChangeTime() {
11721182 */
11731183 protected function cleanPublic () {
11741184
1175- // find all of the patterns in public/. sort by the children first
1176- $ objects = new \RecursiveIteratorIterator (new \RecursiveDirectoryIterator ($ this ->pd ."/patterns/ " ), \RecursiveIteratorIterator::CHILD_FIRST );
1177-
1178- // make sure dots are skipped
1179- $ objects ->setFlags (\FilesystemIterator::SKIP_DOTS );
1180-
1181- // for each file figure out what to do with it
1182- foreach ($ objects as $ name => $ object ) {
1185+ // make sure patterns exists before trying to clean it
1186+ if (is_dir ($ this ->pd ."/patterns " )) {
1187+
1188+ $ objects = new \RecursiveIteratorIterator (new \RecursiveDirectoryIterator ($ this ->pd ."/patterns/ " ), \RecursiveIteratorIterator::CHILD_FIRST );
1189+
1190+ // make sure dots are skipped
1191+ $ objects ->setFlags (\FilesystemIterator::SKIP_DOTS );
11831192
1184- if ($ object ->isDir ()) {
1185- // if this is a directory remove it
1186- rmdir ($ name );
1187- } else if ($ object ->isFile () && ($ object ->getFilename () != "README " )) {
1188- // if this is a file remove it
1189- unlink ($ name );
1193+ // for each file figure out what to do with it
1194+ foreach ($ objects as $ name => $ object ) {
1195+
1196+ if ($ object ->isDir ()) {
1197+ // if this is a directory remove it
1198+ rmdir ($ name );
1199+ } else if ($ object ->isFile () && ($ object ->getFilename () != "README " )) {
1200+ // if this is a file remove it
1201+ unlink ($ name );
1202+ }
1203+
11901204 }
11911205
11921206 }
0 commit comments