From 5d933693f3117988a7107478feb4114f2d0af81f Mon Sep 17 00:00:00 2001 From: Rasmus Schultz Date: Thu, 1 Nov 2012 11:22:14 -0300 Subject: [PATCH] support -f and -c with -w The command-line script was ignoring -f and -c when -w was enabled --- plessc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plessc b/plessc index 3660cc71..1a5dc527 100755 --- a/plessc +++ b/plessc @@ -26,11 +26,10 @@ $opts = getopt('hvrwncXTf:', array('help')); while (count($argv) > 0 && preg_match('/^-([-hvrwncXT]$|[f]=)/', $argv[0])) { array_shift($argv); } - function has() { global $opts; foreach (func_get_args() as $arg) { - if (isset($opts[$arg])) return true; + if (array_key_exists($arg, $opts)) return true; } return false; } @@ -137,8 +136,19 @@ if (has("w")) { if ($updated) { $last_action = time(); + $l = new lessc(); + + if (has("f")) { + $format = $opts["f"]; + if ($format != "default") $l->setFormatter($format); + } + + if (has("c")) { + $l->setPreserveComments(true); + } + try { - $cache = lessc::cexecute($cache); + $cache = lessc::cexecute($cache, false, $l); echo "Writing updated file: ".$out."\n"; if (!file_put_contents($out, $cache['compiled'])) { err($fa."Could not write to file ".$out);