From 8bff475612e4668972f3cf13bf8ffe48a6da31a3 Mon Sep 17 00:00:00 2001 From: Shohei Ueda <30958501+peaceiris@users.noreply.github.com> Date: Mon, 22 Jun 2020 05:40:06 +0900 Subject: [PATCH] chore: change printWidth from 80 to 100 (#365) --- .prettierrc.json | 20 ++++++++++---------- __tests__/get-latest-version.test.ts | 24 +++++------------------- __tests__/get-url.test.ts | 3 +-- __tests__/main.test.ts | 24 ++++++------------------ package.json | 2 +- src/get-latest-version.ts | 6 +----- src/get-url.ts | 6 +----- src/installer.ts | 10 ++-------- src/main.ts | 5 +---- 9 files changed, 28 insertions(+), 72 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 97b6e6d..05b31a8 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,11 +1,11 @@ { - "printWidth": 80, - "tabWidth": 2, - "useTabs": false, - "semi": true, - "singleQuote": true, - "trailingComma": "none", - "bracketSpacing": false, - "arrowParens": "avoid", - "parser": "typescript" - } + "printWidth": 100, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": true, + "trailingComma": "none", + "bracketSpacing": false, + "arrowParens": "avoid", + "parser": "typescript" +} diff --git a/__tests__/get-latest-version.test.ts b/__tests__/get-latest-version.test.ts index fea6fc8..e30ca5c 100644 --- a/__tests__/get-latest-version.test.ts +++ b/__tests__/get-latest-version.test.ts @@ -27,15 +27,9 @@ describe('getURL()', () => { describe('getLatestVersion()', () => { test('return latest version via brew', async () => { - nock('https://formulae.brew.sh') - .get(`/api/formula/${Tool.Repo}.json`) - .reply(200, jsonTestBrew); + nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew); - const versionLatest: string = await getLatestVersion( - Tool.Org, - Tool.Repo, - 'brew' - ); + const versionLatest: string = await getLatestVersion(Tool.Org, Tool.Repo, 'brew'); expect(versionLatest).toMatch(Tool.TestVersionLatest); }); @@ -44,21 +38,13 @@ describe('getLatestVersion()', () => { .get(`/repos/${Tool.Org}/${Tool.Repo}/releases/latest`) .reply(200, jsonTestGithub); - const versionLatest: string = await getLatestVersion( - Tool.Org, - Tool.Repo, - 'github' - ); + const versionLatest: string = await getLatestVersion(Tool.Org, Tool.Repo, 'github'); expect(versionLatest).toMatch(Tool.TestVersionLatest); }); test('return exception 404', async () => { - nock('https://formulae.brew.sh') - .get(`/api/formula/${Tool.Repo}.json`) - .reply(404); + nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404); - await expect( - getLatestVersion(Tool.Org, Tool.Repo, 'brew') - ).rejects.toThrowError(FetchError); + await expect(getLatestVersion(Tool.Org, Tool.Repo, 'brew')).rejects.toThrowError(FetchError); }); }); diff --git a/__tests__/get-url.test.ts b/__tests__/get-url.test.ts index 09bffe0..d98b31c 100644 --- a/__tests__/get-url.test.ts +++ b/__tests__/get-url.test.ts @@ -2,8 +2,7 @@ import getURL from '../src/get-url'; describe('getURL()', () => { test('test', () => { - const baseURL = - 'https://github.com/gohugoio/hugo/releases/download/v0.58.2'; + const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2'; const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`; const urlLinuxExtended = `${baseURL}/hugo_extended_0.58.2_Linux-64bit.tar.gz`; const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`; diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 86a556a..0735793 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -43,36 +43,26 @@ describe('Integration testing run()', () => { test('succeed in installing the latest version', async () => { const testVersion = 'latest'; process.env['INPUT_HUGO-VERSION'] = testVersion; - nock('https://formulae.brew.sh') - .get(`/api/formula/${Tool.Repo}.json`) - .reply(200, jsonTestBrew); + nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew); const result: main.ActionResult = await main.run(); expect(result.exitcode).toBe(0); - expect(result.output).toMatch( - `Hugo Static Site Generator v${Tool.TestVersionLatest}` - ); + expect(result.output).toMatch(`Hugo Static Site Generator v${Tool.TestVersionLatest}`); }); test('succeed in installing the latest extended version', async () => { const testVersion = 'latest'; process.env['INPUT_HUGO-VERSION'] = testVersion; process.env['INPUT_EXTENDED'] = 'true'; - nock('https://formulae.brew.sh') - .get(`/api/formula/${Tool.Repo}.json`) - .reply(200, jsonTestBrew); + nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew); const result: main.ActionResult = await main.run(); expect(result.exitcode).toBe(0); - expect(result.output).toMatch( - `Hugo Static Site Generator v${Tool.TestVersionLatest}` - ); + expect(result.output).toMatch(`Hugo Static Site Generator v${Tool.TestVersionLatest}`); expect(result.output).toMatch(`extended`); }); test('fail to install the latest version due to 404 of brew', async () => { process.env['INPUT_HUGO-VERSION'] = 'latest'; - nock('https://formulae.brew.sh') - .get(`/api/formula/${Tool.Repo}.json`) - .reply(404); + nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404); await expect(main.run()).rejects.toThrowError(FetchError); }); @@ -91,8 +81,6 @@ describe('showVersion()', () => { }); test('return not found', async () => { - await expect( - main.showVersion('gitgit', ['--version']) - ).rejects.toThrowError(Error); + await expect(main.showVersion('gitgit', ['--version'])).rejects.toThrowError(Error); }); }); diff --git a/package.json b/package.json index 761a515..4686b32 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ } }, "lint-staged": { - "src/**/*.ts": [ + "{src,__tests__}/**/*.ts": [ "prettier --check", "eslint" ], diff --git a/src/get-latest-version.ts b/src/get-latest-version.ts index 5922830..42e711c 100644 --- a/src/get-latest-version.ts +++ b/src/get-latest-version.ts @@ -12,11 +12,7 @@ export function getURL(org: string, repo: string, api: string): string { return url; } -export async function getLatestVersion( - org: string, - repo: string, - api: string -): Promise { +export async function getLatestVersion(org: string, repo: string, api: string): Promise { const url = getURL(org, repo, api); const response = await fetch(url); const json = await response.json(); diff --git a/src/get-url.ts b/src/get-url.ts index ea9726c..95a5735 100644 --- a/src/get-url.ts +++ b/src/get-url.ts @@ -1,8 +1,4 @@ -export default function getURL( - os: string, - extended: string, - version: string -): string { +export default function getURL(os: string, extended: string, version: string): string { const extendedStr = (extended: string): string => { if (extended === 'true') { return 'extended_'; diff --git a/src/installer.ts b/src/installer.ts index 48f53e9..c8c3c22 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -59,16 +59,10 @@ export async function installer(version: string): Promise { const toolAssets: string = await tc.downloadTool(toolURL); let toolBin = ''; if (process.platform === 'win32') { - const toolExtractedFolder: string = await tc.extractZip( - toolAssets, - tempDir - ); + const toolExtractedFolder: string = await tc.extractZip(toolAssets, tempDir); toolBin = `${toolExtractedFolder}/${Tool.CmdName}.exe`; } else { - const toolExtractedFolder: string = await tc.extractTar( - toolAssets, - tempDir - ); + const toolExtractedFolder: string = await tc.extractTar(toolAssets, tempDir); toolBin = `${toolExtractedFolder}/${Tool.CmdName}`; } await io.mv(toolBin, binDir); diff --git a/src/main.ts b/src/main.ts index 7784223..2e375e2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,10 +9,7 @@ export interface ActionResult { output: string; } -export async function showVersion( - cmd: string, - args: string[] -): Promise { +export async function showVersion(cmd: string, args: string[]): Promise { const result: ActionResult = { exitcode: 0, output: ''