Пример #1
0
 /**
  * scssphp compiler
  * @link https://github.com/leafo/scssphp
  *
  * @param string $file
  * @return string
  */
 protected function scssphp($file)
 {
     if (!class_exists('\\Leafo\\ScssPhp\\Compiler')) {
         return Result::errorMissingPackage($this, 'scssphp', 'leafo/scssphp');
     }
     $scssCode = file_get_contents($file);
     $scss = new \Leafo\ScssPhp\Compiler();
     // set options for the scssphp compiler
     if (isset($this->compilerOptions['importDirs'])) {
         $scss->setImportPaths($this->compilerOptions['importDirs']);
     }
     if (isset($this->compilerOptions['formatter'])) {
         $scss->setFormatter($this->compilerOptions['formatter']);
     }
     return $scss->compile($scssCode);
 }
Пример #2
0
Файл: Less.php Проект: jjok/Robo
 /**
  * less compiler
  * @link https://github.com/oyejorge/less.php
  *
  * @param string $file
  *
  * @return string
  */
 protected function less($file)
 {
     if (!class_exists('\\Less_Parser')) {
         return Result::errorMissingPackage($this, 'Less_Parser', 'oyejorge/less.php');
     }
     $lessCode = file_get_contents($file);
     $parser = new \Less_Parser();
     $parser->SetOptions($this->compilerOptions);
     if (isset($this->compilerOptions['importDirs'])) {
         $importDirs = [];
         foreach ($this->compilerOptions['importDirs'] as $dir) {
             $importDirs[$dir] = $dir;
         }
         $parser->SetImportDirs($importDirs);
     }
     $parser->parse($lessCode);
     return $parser->getCss();
 }
Пример #3
0
 public function run()
 {
     if (!class_exists('Lurker\\ResourceWatcher')) {
         return Result::errorMissingPackage($this, 'ResourceWatcher', 'henrikbjorn/lurker');
     }
     $watcher = new ResourceWatcher();
     foreach ($this->monitor as $k => $monitor) {
         $closure = $monitor[1];
         $closure->bindTo($this->bindTo);
         foreach ($monitor[0] as $i => $dir) {
             $watcher->track("fs.{$k}.{$i}", $dir, FilesystemEvent::MODIFY);
             $this->printTaskInfo('Watching {dir} for changes...', ['dir' => $dir]);
             $watcher->addListener("fs.{$k}.{$i}", $closure);
         }
     }
     $watcher->start();
     return Result::success($this);
 }
Пример #4
0
 protected function extractTar($extractLocation)
 {
     if (!class_exists('Archive_Tar')) {
         return Result::errorMissingPackage($this, 'Archive_Tar', 'pear/archive_tar');
     }
     $tar_object = new \Archive_Tar($this->filename);
     if (!$tar_object->extract($extractLocation)) {
         return Result::error($this, "Could not extract tar archive {$this->filename}");
     }
     return Result::success($this);
 }
Пример #5
0
 /**
  * Minifies and returns text.
  *
  * @return string|bool
  */
 protected function getMinifiedText()
 {
     switch ($this->type) {
         case 'css':
             if (!class_exists('\\CssMin')) {
                 return Result::errorMissingPackage($this, 'CssMin', 'natxet/CssMin');
             }
             return \CssMin::minify($this->text);
             break;
         case 'js':
             if (!class_exists('\\JSqueeze') && !class_exists('\\Patchwork\\JSqueeze')) {
                 return Result::errorMissingPackage($this, 'Patchwork\\JSqueeze', 'patchwork/jsqueeze');
             }
             if (class_exists('\\JSqueeze')) {
                 $jsqueeze = new \JSqueeze();
             } else {
                 $jsqueeze = new \Patchwork\JSqueeze();
             }
             return $jsqueeze->squeeze($this->text, $this->squeezeOptions['singleLine'], $this->squeezeOptions['keepImportantComments'], $this->squeezeOptions['specialVarRx']);
             break;
     }
     return false;
 }
Пример #6
0
 protected function archiveTar($archiveFile, $items)
 {
     if (!class_exists('Archive_Tar')) {
         return Result::errorMissingPackage($this, 'Archive_Tar', 'pear/archive_tar');
     }
     $tar_object = new \Archive_Tar($archiveFile);
     foreach ($items as $placementLocation => $filesystemLocation) {
         $p_remove_dir = $filesystemLocation;
         $p_add_dir = $placementLocation;
         if (is_file($filesystemLocation)) {
             $p_remove_dir = dirname($filesystemLocation);
             $p_add_dir = dirname($placementLocation);
             if (basename($filesystemLocation) != basename($placementLocation)) {
                 return Result::error($this, "Tar archiver does not support renaming files during extraction; could not add {$filesystemLocation} as {$placementLocation}.");
             }
         }
         if (!$tar_object->addModify([$filesystemLocation], $p_add_dir, $p_remove_dir)) {
             return Result::error($this, "Could not add {$filesystemLocation} to the archive.");
         }
     }
     return Result::success($this);
 }
Пример #7
0
 /**
  * less compiler
  *
  * @link https://github.com/oyejorge/less.php
  * @return string
  */
 protected function less($file)
 {
     if (!class_exists('\\Less_Parser')) {
         return Result::errorMissingPackage($this, 'Less_Parser', 'oyejorge/less.php');
     }
     $lessCode = file_get_contents($file);
     $parser = new \Less_Parser();
     $parser->parse($lessCode);
     return $parser->getCss();
 }