Skip to content

Commit 72a615c

Browse files
authored
fix: replace return with continue in for loop (#20)
Refs: #19
1 parent 584589c commit 72a615c

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

Diff for: dist/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31070,11 +31070,11 @@ function exportSecrets(core) {
3107031070
for (const [key, value] of Object.entries(secrets)) {
3107131071
if (downcaseTfVar && key.startsWith("TF_VAR_")) {
3107231072
core.exportVariable(`TF_VAR_${key.replace(/^TF_VAR_/, "").toLowerCase()}`, value);
31073-
return;
31073+
continue;
3107431074
}
3107531075
if (downcaseTfToken && key.startsWith("TF_TOKEN_")) {
3107631076
core.exportVariable(`TF_TOKEN_${key.replace(/^TF_TOKEN_/, "").toLowerCase()}`, value);
31077-
return;
31077+
continue;
3107831078
}
3107931079
core.exportVariable(key, value);
3108031080
}

Diff for: src/lib.test.ts

+27-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("exportSecrets()", () => {
88
getInput: vi.fn().mockImplementation((s: string) => {
99
switch (s) {
1010
case "secrets":
11-
return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D"}';
11+
return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D","TF_TOKEN_KEY_E":"VALUE_E"}';
1212
case "downcase-tf-var":
1313
return "";
1414
case "downcase-tf-token":
@@ -59,19 +59,24 @@ describe("exportSecrets()", () => {
5959
"TF_VAR_KEY_D",
6060
"VALUE_D",
6161
);
62+
expect(coreMock.exportVariable).toHaveBeenNthCalledWith(
63+
5,
64+
"TF_TOKEN_KEY_E",
65+
"VALUE_E",
66+
);
6267
});
6368
});
6469

65-
describe("success_downcase-tf-token", () => {
70+
describe("success_downcase-tf-var", () => {
6671
const coreMock = {
6772
getInput: vi.fn().mockImplementation((s: string) => {
6873
switch (s) {
6974
case "secrets":
70-
return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_TOKEN_EXAMPLE_COM":"xyz"}';
75+
return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D","TF_TOKEN_KEY_E":"VALUE_E"}';
7176
case "downcase-tf-var":
72-
return "";
73-
case "downcase-tf-token":
7477
return "true";
78+
case "downcase-tf-token":
79+
return "";
7580
default:
7681
return "";
7782
}
@@ -115,22 +120,27 @@ describe("exportSecrets()", () => {
115120
);
116121
expect(coreMock.exportVariable).toHaveBeenNthCalledWith(
117122
4,
118-
"TF_TOKEN_example_com",
119-
"xyz",
123+
"TF_VAR_key_d",
124+
"VALUE_D",
125+
);
126+
expect(coreMock.exportVariable).toHaveBeenNthCalledWith(
127+
5,
128+
"TF_TOKEN_KEY_E",
129+
"VALUE_E",
120130
);
121131
});
122132
});
123133

124-
describe("success_downcase-tf-var", () => {
134+
describe("success_downcase-tf-token", () => {
125135
const coreMock = {
126136
getInput: vi.fn().mockImplementation((s: string) => {
127137
switch (s) {
128138
case "secrets":
129-
return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D"}';
139+
return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D","TF_TOKEN_KEY_E":"VALUE_E"}';
130140
case "downcase-tf-var":
131-
return "true";
132-
case "downcase-tf-token":
133141
return "";
142+
case "downcase-tf-token":
143+
return "true";
134144
default:
135145
return "";
136146
}
@@ -174,9 +184,14 @@ describe("exportSecrets()", () => {
174184
);
175185
expect(coreMock.exportVariable).toHaveBeenNthCalledWith(
176186
4,
177-
"TF_VAR_key_d",
187+
"TF_VAR_KEY_D",
178188
"VALUE_D",
179189
);
190+
expect(coreMock.exportVariable).toHaveBeenNthCalledWith(
191+
5,
192+
"TF_TOKEN_key_e",
193+
"VALUE_E",
194+
);
180195
});
181196
});
182197

Diff for: src/lib.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ export function exportSecrets(core: ActionsCore) {
2222
`TF_VAR_${key.replace(/^TF_VAR_/, "").toLowerCase()}`,
2323
value,
2424
);
25-
return;
25+
continue;
2626
}
2727

2828
if (downcaseTfToken && key.startsWith("TF_TOKEN_")) {
2929
core.exportVariable(
3030
`TF_TOKEN_${key.replace(/^TF_TOKEN_/, "").toLowerCase()}`,
3131
value,
3232
);
33-
return;
33+
continue;
3434
}
3535

3636
core.exportVariable(key, value);

0 commit comments

Comments
 (0)