Skip to content

Commit b335194

Browse files
committed
Don't add installation to path
Unlike the `arduino/setup-arduino-cli` action this was based on, this is a standalone action. So adding the installation to the system path would only serve to pollute the runner environment.
1 parent 59f3453 commit b335194

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

__tests__/main.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe("installer tests", () => {
4343
});
4444

4545
it("Downloads version of arduino-lint if no matching version is installed", async () => {
46-
await installer.getArduinoLint("0.4.0");
46+
const toolPath = await installer.getArduinoLint("0.4.0");
4747
const bindir = path.join(
4848
toolDir,
4949
"arduino-lint",
@@ -52,6 +52,7 @@ describe("installer tests", () => {
5252
"arduino-lint"
5353
);
5454

55+
expect(toolPath == path.join(bindir, "arduino-lint")).toBe(true);
5556
expect(fs.existsSync(`${bindir}.complete`)).toBe(true);
5657

5758
if (IS_WINDOWS) {

dist/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function getArduinoLint(version) {
8080
toolPath = yield downloadRelease(version);
8181
core.debug("arduino-lint cached under " + toolPath);
8282
}
83-
core.addPath(`${toolPath}/arduino-lint`);
83+
return path.join(toolPath, "arduino-lint");
8484
});
8585
}
8686
exports.getArduinoLint = getArduinoLint;
@@ -272,8 +272,9 @@ function run() {
272272
const reportFile = core.getInput("report-file");
273273
const verbose = core.getInput("verbose");
274274
const official = core.getInput("official");
275+
let toolPath = "arduino-lint";
275276
if (version) {
276-
yield installer.getArduinoLint(version);
277+
toolPath = yield installer.getArduinoLint(version);
277278
}
278279
const execArgs = [
279280
"--compliance",
@@ -303,7 +304,7 @@ function run() {
303304
ARDUINO_LINT_OFFICIAL: official,
304305
},
305306
};
306-
yield exec.exec("arduino-lint", execArgs, options);
307+
yield exec.exec(toolPath, execArgs, options);
307308
}
308309
catch (error) {
309310
core.setFailed(error.message);

src/installer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface ITaskRef {
3333
ref: string;
3434
}
3535

36-
export async function getArduinoLint(version: string) {
36+
export async function getArduinoLint(version: string): Promise<string> {
3737
// resolve the version number
3838
const targetVersion = await computeVersion(version);
3939
if (targetVersion) {
@@ -50,7 +50,7 @@ export async function getArduinoLint(version: string) {
5050
core.debug("arduino-lint cached under " + toolPath);
5151
}
5252

53-
core.addPath(`${toolPath}/arduino-lint`);
53+
return path.join(toolPath, "arduino-lint");
5454
}
5555

5656
async function downloadRelease(version: string): Promise<string> {

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ async function run() {
1414
const verbose = core.getInput("verbose");
1515
const official = core.getInput("official");
1616

17+
let toolPath = "arduino-lint";
1718
if (version) {
18-
await installer.getArduinoLint(version);
19+
toolPath = await installer.getArduinoLint(version);
1920
}
2021

2122
const execArgs = [
@@ -53,7 +54,7 @@ async function run() {
5354
},
5455
};
5556

56-
await exec.exec("arduino-lint", execArgs, options);
57+
await exec.exec(toolPath, execArgs, options);
5758
} catch (error) {
5859
core.setFailed(error.message);
5960
}

0 commit comments

Comments
 (0)