mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-27 15:19:57 +09:00
Add formatting libraries to composer.json
This commit is contained in:
parent
59ee4a7387
commit
2b008f7be6
202 changed files with 28022 additions and 133 deletions
182
vendor/leafo/scssphp/bin/pscss
vendored
Executable file
182
vendor/leafo/scssphp/bin/pscss
vendored
Executable file
|
|
@ -0,0 +1,182 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2015 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://leafo.github.io/scssphp
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.3') < 0) {
|
||||
die('Requires PHP 5.3 or above');
|
||||
}
|
||||
|
||||
include __DIR__ . '/../scss.inc.php';
|
||||
|
||||
use Leafo\ScssPhp\Compiler;
|
||||
use Leafo\ScssPhp\Parser;
|
||||
use Leafo\ScssPhp\Version;
|
||||
|
||||
$style = null;
|
||||
$loadPaths = null;
|
||||
$precision = null;
|
||||
$dumpTree = false;
|
||||
$inputFile = null;
|
||||
$changeDir = false;
|
||||
$debugInfo = false;
|
||||
$lineNumbers = false;
|
||||
|
||||
/**
|
||||
* Parse argument
|
||||
*
|
||||
* @param integer $i
|
||||
* @param array $options
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function parseArgument(&$i, $options) {
|
||||
global $argc;
|
||||
global $argv;
|
||||
|
||||
if (! preg_match('/^(?:' . implode('|', (array) $options) . ')=?(.*)/', $argv[$i], $matches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($matches[1])) {
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
if ($i + 1 < $argc) {
|
||||
$i++;
|
||||
|
||||
return $argv[$i];
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 1; $i < $argc; $i++) {
|
||||
if ($argv[$i] === '-h' || $argv[$i] === '--help') {
|
||||
$exe = $argv[0];
|
||||
|
||||
$HELP = <<<EOT
|
||||
Usage: $exe [options] [input-file]
|
||||
|
||||
Options include:
|
||||
|
||||
--debug-info Annotate selectors with CSS referring to the source file and line number
|
||||
-h, --help Show this message
|
||||
-f=format Set the output format (compact, compressed, crunched, expanded, or nested)
|
||||
-i=path Set import path
|
||||
--line-numbers Annotate selectors with comments referring to the source file and line number
|
||||
-p=precision Set decimal number precision (default 5)
|
||||
-T Dump formatted parse tree
|
||||
-v, --version Print the version
|
||||
|
||||
EOT;
|
||||
exit($HELP);
|
||||
}
|
||||
|
||||
if ($argv[$i] === '-v' || $argv[$i] === '--version') {
|
||||
exit(Version::VERSION . "\n");
|
||||
}
|
||||
|
||||
if ($argv[$i] === '--debug-info') {
|
||||
$debugInfo = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($argv[$i] === '--line-numbers' || $argv[$i] === '--line-comments') {
|
||||
$lineNumbers = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($argv[$i] === '-T') {
|
||||
$dumpTree = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = parseArgument($i, array('-f', '--style'));
|
||||
|
||||
if (isset($value)) {
|
||||
$style = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = parseArgument($i, array('-i', '--load_paths'));
|
||||
|
||||
if (isset($value)) {
|
||||
$loadPaths = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = parseArgument($i, array('-p', '--precision'));
|
||||
|
||||
if (isset($value)) {
|
||||
$precision = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file_exists($argv[$i])) {
|
||||
$inputFile = $argv[$i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($inputFile) {
|
||||
$data = file_get_contents($inputFile);
|
||||
|
||||
$newWorkingDir = dirname(realpath($inputFile));
|
||||
$oldWorkingDir = getcwd();
|
||||
|
||||
if ($oldWorkingDir !== $newWorkingDir) {
|
||||
$changeDir = chdir($newWorkingDir);
|
||||
$inputFile = basename($inputFile);
|
||||
}
|
||||
} else {
|
||||
$data = '';
|
||||
|
||||
while (! feof(STDIN)) {
|
||||
$data .= fread(STDIN, 8192);
|
||||
}
|
||||
}
|
||||
|
||||
if ($dumpTree) {
|
||||
$parser = new Parser($inputFile);
|
||||
|
||||
print_r(json_decode(json_encode($parser->parse($data)), true));
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
$scss = new Compiler();
|
||||
|
||||
if ($debugInfo && $inputFile) {
|
||||
$scss->setLineNumberStyle(Compiler::DEBUG_INFO);
|
||||
}
|
||||
|
||||
if ($lineNumbers && $inputFile) {
|
||||
$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
|
||||
}
|
||||
|
||||
if ($loadPaths) {
|
||||
$scss->setImportPaths(explode(PATH_SEPARATOR, $loadPaths));
|
||||
}
|
||||
|
||||
if ($precision) {
|
||||
$scss->setNumberPrecision($precision);
|
||||
}
|
||||
|
||||
if ($style) {
|
||||
$scss->setFormatter('Leafo\\ScssPhp\\Formatter\\' . ucfirst($style));
|
||||
}
|
||||
|
||||
echo $scss->compile($data, $inputFile);
|
||||
|
||||
if ($changeDir) {
|
||||
chdir($oldWorkingDir);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue