Example #1
0
 /**
  * Compile function. Returns a compile content, or writes it to a file if path is specified.
  *
  * @param null|string $file
  * @return string|true
  */
 public function compile($path = null)
 {
     parent::compile();
     $file = $this->getMinifiedResource();
     $file->rewind();
     $scss = new \scssc();
     $string = $scss->compile($file->read());
     if (null !== $path) {
         $file2 = new FileObject($path, 'w+');
         $file2->write($string);
         $string = true;
     }
     unset($file);
     unset($file2);
     return $string;
 }
Example #2
0
 /**
  * Compile function. Returns a compile content, or writes it to a file if path is specified.
  *
  * @param null|string $file
  * @return string|true
  */
 public function compile($path = null)
 {
     parent::compile();
     $file = $this->getMinifiedResource();
     $file->rewind();
     $filePath = $file->getPath() . '/' . $file->getFilename();
     $stylus = new StylusCompiler();
     $string = $stylus->parseFile($filePath);
     if (null !== $path) {
         $file2 = new FileObject($path, 'w+');
         $file2->write($string);
         $string = true;
     }
     unset($file);
     unset($file2);
     return $string;
 }
Example #3
0
 /**
  * @return string
  */
 public function compile($path = null)
 {
     parent::compile();
     $file = $this->getMinifiedResource();
     $file->rewind();
     $rand = false;
     if (null === $path) {
         $path = $this->options['tmp'] . '/' . StringUtils::randString(50);
         $rand = true;
     }
     $cmd = sprintf($this->options['cli_run'], $file->getPath() . '/' . $file->getFilename(), $path);
     $out = exec($cmd, $output, $return);
     unset($file);
     if ($return) {
         throw new Exception\ShellExec(sprintf('External minify tool failed executing. To understand the problem, ' . 'please try running in command line: \'%s\' ', $cmd));
     }
     $this->res = $rand ? new FileObject($path, 'r') : new TempFileObject($path, 'r');
     // return the minified text as a string or as a file
     $string = $rand ? trim($this->res->read()) : true;
     return $string;
 }