forked from sfdx-actions/setup-pmd
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
33 lines (30 loc) · 1.06 KB
/
index.js
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
const core = require('@actions/core')
const exec = require('child_process').exec
try {
let version = core.getInput('pmd-version');
installPMD(version)
} catch (error) {
core.setFailed(error.message)
}
function installPMD(version) {
var download = `wget https://github.com/pmd/pmd/releases/download/pmd_releases%2F${version}/pmd-bin-${version}.zip -P /tmp`
var unzip = `unzip /tmp/pmd-bin-${version}.zip -d /tmp`
var mk = 'mkdir $HOME/pmd'
var mv = `mv /tmp/pmd-bin-${version}/* $HOME/pmd`
exec(download + ' && ' + unzip + ' && ' + mk + ' && ' + mv, function (error, stdout, stderr) {
if (error) core.setFailed(stderr)
core.debug(stdout)
referencePMD()
})
}
function referencePMD() {
var mk = 'sudo mkdir -p /snap/bin && sudo chmod -R 757 /snap/bin'
var cmd =
`sudo echo '#! /bin/bash
$HOME/pmd/bin/run.sh pmd "$@"' > /snap/bin/pmd`
var cm = 'chmod +x /snap/bin/pmd'
exec(mk + ' && ' + cmd + ' && ' + cm, function (error, stdout, stderr) {
if (error) core.setFailed(stderr)
core.debug(stdout)
})
}