#!/usr/bin/env php 0) { switch ($argv[0]) { case '-i': array_shift($argv); $input_dir = array_shift($argv); break; default: cli::die('unsupported argument: '.$argv[0]); } } if (is_null($input_dir)) cli::die("input directory has not been specified"); $hashes = []; foreach (['css', 'js'] as $type) { $entries = glob_recursive($input_dir.'/dist-'.$type.'/*.'.$type); if (empty($entries)) { cli::error("warning: no files found in $input_dir/dist-$type"); continue; } foreach ($entries as $file) { $hashes[$type.'/'.basename($file)] = [ 'version' => get_hash($file), 'integrity' => [] ]; foreach (RESOURCE_INTEGRITY_HASHES as $hash_type) $hashes[$type.'/'.basename($file)]['integrity'][$hash_type] = base64_encode(hash_file($hash_type, $file, true)); } } echo "