From 5ee37f14842852931cb987e86d63ffb679abd036 Mon Sep 17 00:00:00 2001 From: eric sciple Date: Tue, 19 Oct 2021 09:52:57 -0500 Subject: update dev dependencies and react to new linting rules (#611) --- src/fs-helper.ts | 15 +++++++++------ src/git-auth-helper.ts | 6 +++--- src/git-directory-helper.ts | 4 +++- src/github-api-helper.ts | 5 ++++- src/main.ts | 4 ++-- src/misc/generate-docs.ts | 8 ++++---- src/ref-helper.ts | 4 +++- src/retry-helper.ts | 2 +- 8 files changed, 29 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/fs-helper.ts b/src/fs-helper.ts index c443404..3741d35 100644 --- a/src/fs-helper.ts +++ b/src/fs-helper.ts @@ -9,7 +9,7 @@ export function directoryExistsSync(path: string, required?: boolean): boolean { try { stats = fs.statSync(path) } catch (error) { - if (error.code === 'ENOENT') { + if ((error as any)?.code === 'ENOENT') { if (!required) { return false } @@ -18,7 +18,8 @@ export function directoryExistsSync(path: string, required?: boolean): boolean { } throw new Error( - `Encountered an error when checking whether path '${path}' exists: ${error.message}` + `Encountered an error when checking whether path '${path}' exists: ${(error as any) + ?.message ?? error}` ) } @@ -39,12 +40,13 @@ export function existsSync(path: string): boolean { try { fs.statSync(path) } catch (error) { - if (error.code === 'ENOENT') { + if ((error as any)?.code === 'ENOENT') { return false } throw new Error( - `Encountered an error when checking whether path '${path}' exists: ${error.message}` + `Encountered an error when checking whether path '${path}' exists: ${(error as any) + ?.message ?? error}` ) } @@ -60,12 +62,13 @@ export function fileExistsSync(path: string): boolean { try { stats = fs.statSync(path) } catch (error) { - if (error.code === 'ENOENT') { + if ((error as any)?.code === 'ENOENT') { return false } throw new Error( - `Encountered an error when checking whether path '${path}' exists: ${error.message}` + `Encountered an error when checking whether path '${path}' exists: ${(error as any) + ?.message ?? error}` ) } diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts index 291d83b..af400ab 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -94,7 +94,7 @@ class GitAuthHelper { await fs.promises.stat(gitConfigPath) configExists = true } catch (err) { - if (err.code !== 'ENOENT') { + if ((err as any)?.code !== 'ENOENT') { throw err } } @@ -213,7 +213,7 @@ class GitAuthHelper { await fs.promises.readFile(userKnownHostsPath) ).toString() } catch (err) { - if (err.code !== 'ENOENT') { + if ((err as any)?.code !== 'ENOENT') { throw err } } @@ -302,7 +302,7 @@ class GitAuthHelper { try { await io.rmRF(keyPath) } catch (err) { - core.debug(err.message) + core.debug(`${(err as any)?.message ?? err}`) core.warning(`Failed to remove SSH key '${keyPath}'`) } } diff --git a/src/git-directory-helper.ts b/src/git-directory-helper.ts index e792190..2979e97 100644 --- a/src/git-directory-helper.ts +++ b/src/git-directory-helper.ts @@ -39,7 +39,9 @@ export async function prepareExistingDirectory( try { await io.rmRF(lockPath) } catch (error) { - core.debug(`Unable to delete '${lockPath}'. ${error.message}`) + core.debug( + `Unable to delete '${lockPath}'. ${(error as any)?.message ?? error}` + ) } } diff --git a/src/github-api-helper.ts b/src/github-api-helper.ts index cadd13b..45b979a 100644 --- a/src/github-api-helper.ts +++ b/src/github-api-helper.ts @@ -92,7 +92,10 @@ export async function getDefaultBranch( assert.ok(result, 'default_branch cannot be empty') } catch (err) { // Handle .wiki repo - if (err['status'] === 404 && repo.toUpperCase().endsWith('.WIKI')) { + if ( + (err as any)?.status === 404 && + repo.toUpperCase().endsWith('.WIKI') + ) { result = 'master' } // Otherwise error diff --git a/src/main.ts b/src/main.ts index 4702fe0..07a7ce3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -24,7 +24,7 @@ async function run(): Promise { coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '') } } catch (error) { - core.setFailed(error.message) + core.setFailed(`${(error as any)?.message ?? error}`) } } @@ -32,7 +32,7 @@ async function cleanup(): Promise { try { await gitSourceProvider.cleanup(stateHelper.RepositoryPath) } catch (error) { - core.warning(error.message) + core.warning(`${(error as any)?.message ?? error}`) } } diff --git a/src/misc/generate-docs.ts b/src/misc/generate-docs.ts index defda5a..a1c845d 100644 --- a/src/misc/generate-docs.ts +++ b/src/misc/generate-docs.ts @@ -10,10 +10,10 @@ import * as yaml from 'js-yaml' function updateUsage( actionReference: string, - actionYamlPath: string = 'action.yml', - readmePath: string = 'README.md', - startToken: string = '', - endToken: string = '' + actionYamlPath = 'action.yml', + readmePath = 'README.md', + startToken = '', + endToken = '' ): void { if (!actionReference) { throw new Error('Parameter actionReference must not be empty') diff --git a/src/ref-helper.ts b/src/ref-helper.ts index 381fa60..209f49d 100644 --- a/src/ref-helper.ts +++ b/src/ref-helper.ts @@ -253,7 +253,9 @@ export async function checkCommitInfo( await octokit.repos.get({owner: repositoryOwner, repo: repositoryName}) } } catch (err) { - core.debug(`Error when validating commit info: ${err.stack}`) + core.debug( + `Error when validating commit info: ${(err as any)?.stack ?? err}` + ) } } diff --git a/src/retry-helper.ts b/src/retry-helper.ts index bbc20a1..323e75d 100644 --- a/src/retry-helper.ts +++ b/src/retry-helper.ts @@ -29,7 +29,7 @@ export class RetryHelper { try { return await action() } catch (err) { - core.info(err.message) + core.info((err as any)?.message) } // Sleep -- cgit v1.2.3