Beispiel #1
0
 public function write(StringObject $string)
 {
     $process = $this->process;
     $dir = $this->getOutputDir();
     $filename = $this->getOutputFilename();
     $sourcemapFilename = "{$filename}.map";
     if ($process->sourceMap) {
         $string->append($process->newline . "/*# sourceMappingURL={$sourcemapFilename} */");
     }
     if (Util::filePutContents("{$dir}/{$filename}", $string, __METHOD__)) {
         $jsonFlags = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
         if ($process->sourceMap) {
             Util::filePutContents("{$dir}/{$sourcemapFilename}", json_encode($process->sourceMap, $jsonFlags), __METHOD__);
         }
         if ($process->options->stat_dump) {
             $statFile = is_string($process->options->stat_dump) ? $process->options->stat_dump : "{$dir}/{$filename}.json";
             $GLOBALS['CSSCRUSH_STAT_FILE'] = $statFile;
             Util::filePutContents($statFile, json_encode(csscrush_stat(), $jsonFlags), __METHOD__);
         }
         return true;
     }
     return false;
 }
Beispiel #2
0
 /**
  * Deprecated.
  *
  * @see csscrush_stat().
  */
 public static function stat()
 {
     return csscrush_stat();
 }
Beispiel #3
0
            stderr(message($warnings, array('type' => 'warning')));
        }
        if ($changed && $args->stats) {
            stderr(message($stats, array('type' => 'stats')));
        }
        sleep(1);
    }
} else {
    $stdOutput = null;
    if ($args->input_file && isset($options['output_dir'])) {
        $options['cache'] = false;
        csscrush_file($args->input_file, $options);
    } else {
        $stdOutput = csscrush_string($input, $options);
    }
    $stats = csscrush_stat();
    $errors = $stats['errors'];
    $warnings = $stats['warnings'];
    if ($errors) {
        stderr(message($errors, array('type' => 'error')));
        exit(STATUS_ERROR);
    } elseif ($args->input_file && !empty($stats['output_filename'])) {
        stderr(message(fmt_fileinfo($stats, 'output'), array('type' => 'write')));
    }
    if ($warnings) {
        stderr(message($warnings, array('type' => 'warning')));
    }
    if ($args->stats) {
        stderr(message($stats, array('type' => 'stats')));
    }
    if ($stdOutput) {