Skip to content

Commit b706e4e

Browse files
author
Gabriel Basilio
committed
Format index.js
1 parent 50ab602 commit b706e4e

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

index.js

+38-37
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,54 @@
1-
const core = require('@actions/core');
2-
const exec = require('@actions/exec');
1+
/**
2+
* Author: Gabriel Basilio
3+
*/
4+
const core = require("@actions/core");
5+
const exec = require("@actions/exec");
36

47
async function main() {
5-
6-
try {
7-
if (process.platform == "linux") {
8-
await exec.exec("sudo apt-get update");
9-
await exec.exec("sudo apt-get install -y xvfb x11-xserver-utils");
10-
}
11-
12-
const commands = core.getInput('run', { required: true }).split("\n");
13-
const directory = core.getInput('working-directory');
14-
const serverOptions = core.getInput('options');
15-
16-
for (i in commands) {
17-
if (process.platform == "linux") {
18-
console.log('Command: ' + commands[i]);
19-
await runCommandWithXvfb(commands[i], directory, serverOptions);
20-
} else {
21-
await runCommand(commands[i], directory);
22-
}
23-
}
8+
try {
9+
if (process.platform == "linux") {
10+
await exec.exec("sudo apt-get update");
11+
await exec.exec("sudo apt-get install -y xvfb x11-xserver-utils");
2412
}
25-
catch (error) {
26-
core.setFailed(error.message);
13+
14+
const commands = core.getInput("run", { required: true }).split("\n");
15+
const directory = core.getInput("working-directory");
16+
const serverOptions = core.getInput("options");
17+
18+
for (i in commands) {
19+
if (process.platform == "linux") {
20+
console.log("Command: " + commands[i]);
21+
await runCommandWithXvfb(commands[i], directory, serverOptions);
22+
} else {
23+
await runCommand(commands[i], directory);
24+
}
2725
}
26+
} catch (error) {
27+
core.setFailed(error.message);
28+
}
2829
}
2930

3031
async function runCommandWithXvfb(command, directory, options) {
31-
const optionsArgument = options ? `-s "${options}"` : '';
32-
command = `xvfb-run --auto-servernum ${optionsArgument} ${command}`;
33-
34-
try {
35-
await runCommand(command, directory)
36-
} finally {
37-
await cleanUpXvfb();
38-
}
32+
const optionsArgument = options ? `-s "${options}"` : "";
33+
command = `xvfb-run --auto-servernum ${optionsArgument} ${command}`;
34+
35+
try {
36+
await runCommand(command, directory);
37+
} finally {
38+
await cleanUpXvfb();
39+
}
3940
}
4041

4142
async function cleanUpXvfb() {
42-
try {
43-
await exec.exec("bash", [`${__dirname}/cleanup.sh`]);
44-
} catch {
45-
46-
}
43+
try {
44+
await exec.exec("bash", [`${__dirname}/cleanup.sh`]);
45+
} catch {}
4746
}
4847

4948
async function runCommand(command, directory) {
50-
await (directory ? exec.exec(command, [], {cwd: directory}) : exec.exec(command));
49+
await (directory
50+
? exec.exec(command, [], { cwd: directory })
51+
: exec.exec(command));
5152
}
5253

5354
main();

0 commit comments

Comments
 (0)