Permalink
Browse files

Modified jslint-console to output JSON for errors

  • Loading branch information...
1 parent 53b2637 commit 16c093648a4471acd6f83febdbaf5fe3c8bc45f0 @davglass committed Dec 16, 2008
Showing with 535 additions and 18 deletions.
  1. +13 −10 index.php
  2. +505 −7 lib/jslint/jslint-console.js
  3. +17 −1 tests/post-source.html
View
@@ -1,11 +1,11 @@
<?php
$str = '';
-#$java = `which java`;
+$java = `which java`;
$java = 'java';
$dir = realpath('./');
$jslint = $dir.'/lib/jslint/jslint-console.js';
-//$jslint = $dir.'/lib/jslint/fulljslint.js';
+$fulljslint = $dir.'/lib/jslint/fulljslint.js';
$rhino = $dir.'/lib/rhino/js.jar';
@@ -14,27 +14,30 @@
if ($_POST['source']) {
$str = $_POST['source'];
$tempName = tempnam(sys_get_temp_dir(), 'jslint-');
+ $tempNameOut = tempnam(sys_get_temp_dir(), 'jslint-');
file_put_contents($tempName, stripslashes($str));
chmod($tempName, 0755);
}
if ($tempName) {
- $cmd = $java.' -jar '.escapeshellarg($rhino).' '.escapeshellarg($jslint).' '.escapeshellarg($tempName);
- echo($cmd);
- //$out = exec($cmd, $data);
+ $cmd = $java.' -jar '.escapeshellarg($rhino).' '.escapeshellarg($jslint).' '.$fulljslint.' '.escapeshellarg($tempName).' 2>&1';
+ //echo($cmd);
$out = exec($cmd, $data);
- $fileE = file_get_contents("php://stdin", "r");
- echo $fileE;
+ $error = file_get_contents($tempNameOut);
+ $error = str_replace('js: ', '', $error);
+ $error = str_replace('"'.$tempName.'", ', '', $error);
+
+ //echo('<pre>'.$error.'</pre>');
+ echo($out);
+ //echo('<pre>'.print_r($data, 1).'</pre>');
- echo('<pre>'.print_r($out, 1).'</pre>');
- echo('<pre>'.print_r($data, 1).'</pre>');
} else {
$json->error = new stdclass();
$json->error->message = 'No javascript to lint.';
+ echo(json_encode($json));
}
-echo(json_encode($json));
?>
Oops, something went wrong.

0 comments on commit 16c0936

Please sign in to comment.