Esempio n. 1
0
            $assets += array("css" => array(), "js" => array(), "scss" => array(), "coffee" => array(), "images" => array());
            // cycle through
            foreach ($assets['css'] as $path) {
                $stylesheets = array_merge($stylesheets, get_matching_paths($root, $dir, $path));
            }
            foreach ($assets['js'] as $path) {
                $javascripts = array_merge($javascripts, get_matching_paths($root, $dir, $path));
            }
            foreach ($assets['scss'] as $path) {
                $sasses = array_merge($sasses, get_matching_paths($root, $dir, $path));
            }
            foreach ($assets['coffee'] as $path) {
                $coffeescripts = array_merge($coffeescripts, get_matching_paths($root, $dir, $path));
            }
            foreach ($assets['images'] as $path) {
                $images[] = array('parent' => $dir, 'files' => get_matching_paths($root, $dir, $path));
            }
            $count++;
        }
    }
    echo "Found {$count} asset-producing components\n";
}
echo "Processing " . count($stylesheets) . " stylesheets...\n";
$fp = fopen($json['css'], "w");
if (!$fp) {
    throw new Exception("Could not open destination file '" . $json['css'] . "' for writing");
}
fwrite($fp, "/**\n * Assets discovered by soundasleep/asset-discovery.\n * @generated file DO NOT MODIFY\n */\n");
foreach ($stylesheets as $include) {
    fwrite($fp, "/* '{$include}' */\n");
    fwrite($fp, file_get_contents($include));
 function testGetMatchingPathsPatternParent()
 {
     $paths = get_matching_paths(__DIR__ . "/..", "resources", "*/*.coffee");
     $this->assertEquals(array('resources/1/1.coffee', 'resources/1/2.coffee', 'resources/2/2.coffee'), $paths, "*/*.coffee did not match correctly");
 }
    $filename = "translations.json";
    echo "Processing translation components...\n";
    $count = 0;
    foreach ($selected_dirs as $dir) {
        if (file_exists($dir . "/" . $filename)) {
            $assets = json_decode(file_get_contents($dir . "/" . $filename), true);
            if (!$assets) {
                throw new Exception("Could not load JSON from '{$dir}/{$filename}'");
            }
            foreach ($json['translations'] as $code => $ignored) {
                if (isset($assets[$code])) {
                    if (!is_array($assets[$code])) {
                        $assets[$code] = array($assets[$code]);
                    }
                    foreach ($assets[$code] as $path) {
                        $translations[$code] = array_merge($translations[$code], get_matching_paths($dir, $path));
                    }
                }
            }
            $count++;
        }
    }
    echo "Found {$count} translation-producing components\n";
}
foreach ($translations as $code => $includes) {
    echo "Processing " . count($includes) . " '{$code}' includes...\n";
    $result = array();
    foreach ($includes as $include) {
        $result = array_merge($result, json_decode(file_get_contents($include), true));
    }
    // sort it