10 array_shift($realArgs);
11 foreach ($realArgs as $arg) {
14 $diffCmd = 'diff -wu';
18 $diffCmd = 'colordiff -wu';
27 echo "usage: cleanup-angular.php [--diff|--colordiff] <file>\n";
28 echo "example: cleanup-angular.php '/full/path/to/crmMailing/BlockSummary.html'\n";
29 echo "note: The file path must be absolute.\n";
33 foreach ($files as $file) {
34 compareFile($file, $diffCmd);
38 function compareFile($file, $diffCmd) {
39 $coder = new \Civi\Angular\
Coder();
41 if (!file_exists($file)) {
42 fwrite(STDERR
, "Failed to find file $file (CWD=" . getcwd() . ")\n");
45 $oldMarkup = file_get_contents($file);
46 if ($coder->checkConsistentHtml($oldMarkup)) {
47 echo "File \"$file\" appears sufficiently consistent.\n";
50 $newMarkup = $coder->recode($oldMarkup);
51 $newFile = "{$file}.recoded";
52 echo "File \"$file\" appears to have consistency issues. Created $newFile.\n";
53 file_put_contents($newFile, $newMarkup);
55 passthru($diffCmd . ' ' . escapeshellarg($file) . ' ' . escapeshellarg($newFile));