1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.alchim31.maven.yuicompressor;
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.OutputStream;
26 import java.nio.file.Files;
27
28 import org.codehaus.plexus.util.IOUtil;
29 import org.mozilla.javascript.ErrorReporter;
30
31
32
33
34
35 class JSLintChecker {
36
37
38 private String jslintPath;
39
40
41
42
43
44
45
46 public JSLintChecker() throws IOException {
47 File jslint = File.createTempFile("jslint", ".js");
48 jslint.deleteOnExit();
49 try (InputStream in = getClass().getResourceAsStream("/jslint.js");
50 OutputStream out = Files.newOutputStream(jslint.toPath())) {
51 IOUtil.copy(in, out);
52 }
53 jslintPath = jslint.getCanonicalPath();
54 }
55
56
57
58
59
60
61
62
63
64
65
66
67 public void check(File jsFile, ErrorReporter reporter) throws IOException {
68 String[] args = new String[2];
69 args[0] = jslintPath;
70 args[1] = jsFile.getCanonicalPath();
71 BasicRhinoShell.exec(args, reporter);
72 }
73 }