Skip to content

Commit 4f2055e

Browse files
committed
Turning on no-unsafe-finally
1 parent 5c0227e commit 4f2055e

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

__tests__/git.test.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ describe("git", () => {
3535
}
3636
});
3737

38-
const call = await init();
38+
await init();
3939
expect(execute).toBeCalledTimes(6);
40-
expect(call).toBe("Initialization step complete...");
4140
});
4241

4342
it("should execute commands if an Access Token is provided", async () => {
@@ -51,10 +50,8 @@ describe("git", () => {
5150
}
5251
});
5352

54-
const call = await init();
55-
53+
await init();
5654
expect(execute).toBeCalledTimes(6);
57-
expect(call).toBe("Initialization step complete...");
5855
});
5956

6057
it("should execute commands if SSH is true", async () => {
@@ -68,10 +65,9 @@ describe("git", () => {
6865
}
6966
});
7067

71-
const call = await init();
68+
await init();
7269

7370
expect(execute).toBeCalledTimes(6);
74-
expect(call).toBe("Initialization step complete...");
7571
});
7672

7773
it("should fail if there is no provided GitHub Token, Access Token or SSH bool", async () => {
@@ -87,10 +83,9 @@ describe("git", () => {
8783
ssh: null
8884
});
8985

90-
const call = await init();
86+
await init();
9187
expect(setFailed).toBeCalledTimes(1);
9288
expect(execute).toBeCalledTimes(0);
93-
expect(call).toBe("Initialization step complete...");
9489
});
9590

9691
it("should fail if the build folder begins with a /", async () => {
@@ -104,11 +99,10 @@ describe("git", () => {
10499
}
105100
});
106101

107-
const call = await init();
102+
await init();
108103

109104
expect(setFailed).toBeCalledTimes(1);
110105
expect(execute).toBeCalledTimes(0);
111-
expect(call).toBe("Initialization step complete...");
112106
});
113107

114108
it("should fail if the build folder begins with a ./", async () => {
@@ -122,10 +116,9 @@ describe("git", () => {
122116
}
123117
});
124118

125-
const call = await init();
119+
await init();
126120
expect(setFailed).toBeCalledTimes(1);
127121
expect(execute).toBeCalledTimes(0);
128-
expect(call).toBe("Initialization step complete...");
129122
});
130123

131124
it("should not fail if root is used", async () => {
@@ -139,10 +132,9 @@ describe("git", () => {
139132
}
140133
});
141134

142-
const call = await init();
135+
await init();
143136

144137
expect(execute).toBeCalledTimes(6);
145-
expect(call).toBe("Initialization step complete...");
146138
});
147139
});
148140

@@ -158,9 +150,8 @@ describe("git", () => {
158150
}
159151
});
160152

161-
const call = await generateBranch();
153+
await generateBranch();
162154
expect(execute).toBeCalledTimes(6);
163-
expect(call).toBe("Deployment branch creation step complete... ✅");
164155
});
165156

166157
it("should fail if there is no branch", async () => {
@@ -174,10 +165,9 @@ describe("git", () => {
174165
}
175166
});
176167

177-
const call = await generateBranch();
168+
await generateBranch();
178169
expect(execute).toBeCalledTimes(0);
179170
expect(setFailed).toBeCalledTimes(1);
180-
expect(call).toBe("Deployment branch creation step complete... ✅");
181171
});
182172
});
183173

src/git.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { isNullOrUndefined } from "./util";
1212
/** Generates the branch if it doesn't exist on the remote.
1313
* @returns {Promise}
1414
*/
15-
export async function init(): Promise<any> {
15+
export async function init(): Promise<void> {
1616
try {
1717
if (
1818
isNullOrUndefined(action.accessToken) &&
@@ -48,14 +48,14 @@ export async function init(): Promise<any> {
4848
} catch (error) {
4949
console.log(`There was an error initializing the repository: ${error}`);
5050
} finally {
51-
return Promise.resolve("Initialization step complete...");
51+
console.log("Initialization step complete...");
5252
}
5353
}
5454

5555
/** Switches to the base branch.
5656
* @returns {Promise}
5757
*/
58-
export async function switchToBaseBranch(): Promise<any> {
58+
export async function switchToBaseBranch(): Promise<string> {
5959
await execute(
6060
`git checkout --progress --force ${
6161
action.baseBranch ? action.baseBranch : action.defaultBranch
@@ -69,7 +69,7 @@ export async function switchToBaseBranch(): Promise<any> {
6969
/** Generates the branch if it doesn't exist on the remote.
7070
* @returns {Promise}
7171
*/
72-
export async function generateBranch(): Promise<any> {
72+
export async function generateBranch(): Promise<void> {
7373
try {
7474
if (isNullOrUndefined(action.branch)) {
7575
throw Error("Branch is required.");
@@ -88,14 +88,14 @@ export async function generateBranch(): Promise<any> {
8888
} catch (error) {
8989
setFailed(`There was an error creating the deployment branch: ${error} ❌`);
9090
} finally {
91-
return Promise.resolve("Deployment branch creation step complete... ✅");
91+
console.log("Deployment branch creation step complete... ✅");
9292
}
9393
}
9494

9595
/** Runs the necessary steps to make the deployment.
9696
* @returns {Promise}
9797
*/
98-
export async function deploy(): Promise<any> {
98+
export async function deploy(): Promise<string> {
9999
const temporaryDeploymentDirectory = "gh-action-temp-deployment-folder";
100100
const temporaryDeploymentBranch = "gh-action-temp-deployment-branch";
101101
/*
@@ -160,7 +160,7 @@ export async function deploy(): Promise<any> {
160160

161161
if (!hasFilesToCommit && !action.isTest) {
162162
console.log("There is nothing to commit. Exiting... ✅");
163-
return Promise.resolve();
163+
return Promise.resolve("Exiting early...");
164164
}
165165

166166
// Commits to GitHub.

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { setFailed } from "@actions/core";
22
import { init, deploy } from "./git";
33

44
/** Initializes and runs the action. */
5-
export default async function main() {
5+
export default async function main(): Promise<void> {
66
try {
77
await init();
88
await deploy();

tslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"no-implicit-dependencies": true,
1919
"no-invalid-this": true,
2020
"no-string-throw": true,
21-
"no-unsafe-finally": false,
21+
"no-unsafe-finally": true,
2222
"no-use-before-declare": true,
2323
"no-void-expression": [true, "ignore-arrow-function-shorthand"],
2424
"no-duplicate-imports": true,

0 commit comments

Comments
 (0)