add cli checks to Php code
[roojs1] / buildSDK / less-bootstrap-compiler.php
index c74644e..9f48504 100644 (file)
@@ -1,8 +1,13 @@
 <?php
 
+if (php_sapi_name() != 'cli') {
+    die("CLI ONLY");
+}
+
 $cwd = getcwd();
 
-if (array_pop(explode('/', $cwd)) !== 'roojs1') {
+$cc = explode('/', $cwd);
+if (array_pop($cc) !== 'roojs1') {
     echo "this should be run in roojs1 directory...\n";
     exit;
 }
@@ -23,6 +28,14 @@ $files = array(
         'sourceMapRootpath' => '../less/bootstrap/',
         'variables' => array("@import 'variables.less';")
     ),
+    "{$rootDir}/roojs1/less/bootstrap/bootstrap-light.less" => array(
+        'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
+        'name' => 'bootstrap-light.css',
+        'minify' => 'bootstrap-light.min.css',
+        'sourceMapRootpath' => '../less/bootstrap/',
+        'variables' => array("@import 'variables.less';")
+    ),
+    
     "{$rootDir}/roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
         'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
         'name' => 'roojs-bootstrap-debug.css',
@@ -48,26 +61,29 @@ foreach ($files as $src => $file){
         continue;
     }
     
+    $isLatest = true;
+    
     foreach(scandir($dir) as $f) {
                 
         if (!strlen($f) || $f[0] == '.') {
             continue;
         }
 
-        $less = "{$dir}/{$f}";
-        echo ""
-        if(filemtime($less) < filemtime($css)){
-            echo "'in???\n";
-            continue;
-        }
+        $less = "{$dir}{$f}";
         
+        if(filemtime($less) > filemtime($css)){
+            $isLatest = false;
+            break;
+        }
+    }
+    
+    if($isLatest){
         echo "{$css} already up-to-date \n";
         unset($files[$src]);
-
     }
     
 }
-exit;   
+
 require_once 'HTML/Less.php';
 
 foreach ($files as $src => $file){
@@ -117,5 +133,4 @@ foreach ($files as $src => $file){
     } catch (Exception $ex) {
         echo "lessphp fatal error: {$ex->getMessage()}\n";
     }
-    
 }
\ No newline at end of file