-
Notifications
You must be signed in to change notification settings - Fork 4
/
pmd
executable file
·37 lines (31 loc) · 907 Bytes
/
pmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
const path = require("path");
const jre = require("node-java-connector");
async function main() {
const className = "net.sourceforge.pmd.cli.PmdCli";
const classPath = [
path.resolve(__dirname, "dist", "pmd-bin", "lib", "*"),
];
const args = process.argv.splice(2);
const proc = await jre.executeClassWithCP(className, classPath, args);
// redirect stderr & stdout rather than capturing
proc.stdout.removeAllListeners("data");
proc.stderr.removeAllListeners("data");
proc.stdout.pipe(process.stdout);
if (process.env.NPM_PMD_BIN_STDERR === "true") {
proc.stderr.pipe(process.stderr);
}
return await new Promise(function (resolve, reject) {
proc.on("exit", (exitCode) => {
resolve(exitCode);
});
});
}
main()
.then((result) => {
process.exit(result);
})
.catch((err) => {
console.error(err);
process.exit(-1);
});