chore: change printWidth from 80 to 100 (#365)

This commit is contained in:
Shohei Ueda 2020-06-22 05:40:06 +09:00 committed by GitHub
parent be3787356a
commit 8bff475612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 72 deletions

View File

@ -1,11 +1,11 @@
{ {
"printWidth": 80, "printWidth": 100,
"tabWidth": 2, "tabWidth": 2,
"useTabs": false, "useTabs": false,
"semi": true, "semi": true,
"singleQuote": true, "singleQuote": true,
"trailingComma": "none", "trailingComma": "none",
"bracketSpacing": false, "bracketSpacing": false,
"arrowParens": "avoid", "arrowParens": "avoid",
"parser": "typescript" "parser": "typescript"
} }

View File

@ -27,15 +27,9 @@ describe('getURL()', () => {
describe('getLatestVersion()', () => { describe('getLatestVersion()', () => {
test('return latest version via brew', async () => { test('return latest version via brew', async () => {
nock('https://formulae.brew.sh') nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew);
.get(`/api/formula/${Tool.Repo}.json`)
.reply(200, jsonTestBrew);
const versionLatest: string = await getLatestVersion( const versionLatest: string = await getLatestVersion(Tool.Org, Tool.Repo, 'brew');
Tool.Org,
Tool.Repo,
'brew'
);
expect(versionLatest).toMatch(Tool.TestVersionLatest); expect(versionLatest).toMatch(Tool.TestVersionLatest);
}); });
@ -44,21 +38,13 @@ describe('getLatestVersion()', () => {
.get(`/repos/${Tool.Org}/${Tool.Repo}/releases/latest`) .get(`/repos/${Tool.Org}/${Tool.Repo}/releases/latest`)
.reply(200, jsonTestGithub); .reply(200, jsonTestGithub);
const versionLatest: string = await getLatestVersion( const versionLatest: string = await getLatestVersion(Tool.Org, Tool.Repo, 'github');
Tool.Org,
Tool.Repo,
'github'
);
expect(versionLatest).toMatch(Tool.TestVersionLatest); expect(versionLatest).toMatch(Tool.TestVersionLatest);
}); });
test('return exception 404', async () => { test('return exception 404', async () => {
nock('https://formulae.brew.sh') nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404);
.get(`/api/formula/${Tool.Repo}.json`)
.reply(404);
await expect( await expect(getLatestVersion(Tool.Org, Tool.Repo, 'brew')).rejects.toThrowError(FetchError);
getLatestVersion(Tool.Org, Tool.Repo, 'brew')
).rejects.toThrowError(FetchError);
}); });
}); });

View File

@ -2,8 +2,7 @@ import getURL from '../src/get-url';
describe('getURL()', () => { describe('getURL()', () => {
test('test', () => { test('test', () => {
const baseURL = const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`; const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`;
const urlLinuxExtended = `${baseURL}/hugo_extended_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`; const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`;

View File

@ -43,36 +43,26 @@ describe('Integration testing run()', () => {
test('succeed in installing the latest version', async () => { test('succeed in installing the latest version', async () => {
const testVersion = 'latest'; const testVersion = 'latest';
process.env['INPUT_HUGO-VERSION'] = testVersion; process.env['INPUT_HUGO-VERSION'] = testVersion;
nock('https://formulae.brew.sh') nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew);
.get(`/api/formula/${Tool.Repo}.json`)
.reply(200, jsonTestBrew);
const result: main.ActionResult = await main.run(); const result: main.ActionResult = await main.run();
expect(result.exitcode).toBe(0); expect(result.exitcode).toBe(0);
expect(result.output).toMatch( expect(result.output).toMatch(`Hugo Static Site Generator v${Tool.TestVersionLatest}`);
`Hugo Static Site Generator v${Tool.TestVersionLatest}`
);
}); });
test('succeed in installing the latest extended version', async () => { test('succeed in installing the latest extended version', async () => {
const testVersion = 'latest'; const testVersion = 'latest';
process.env['INPUT_HUGO-VERSION'] = testVersion; process.env['INPUT_HUGO-VERSION'] = testVersion;
process.env['INPUT_EXTENDED'] = 'true'; process.env['INPUT_EXTENDED'] = 'true';
nock('https://formulae.brew.sh') nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(200, jsonTestBrew);
.get(`/api/formula/${Tool.Repo}.json`)
.reply(200, jsonTestBrew);
const result: main.ActionResult = await main.run(); const result: main.ActionResult = await main.run();
expect(result.exitcode).toBe(0); expect(result.exitcode).toBe(0);
expect(result.output).toMatch( expect(result.output).toMatch(`Hugo Static Site Generator v${Tool.TestVersionLatest}`);
`Hugo Static Site Generator v${Tool.TestVersionLatest}`
);
expect(result.output).toMatch(`extended`); expect(result.output).toMatch(`extended`);
}); });
test('fail to install the latest version due to 404 of brew', async () => { test('fail to install the latest version due to 404 of brew', async () => {
process.env['INPUT_HUGO-VERSION'] = 'latest'; process.env['INPUT_HUGO-VERSION'] = 'latest';
nock('https://formulae.brew.sh') nock('https://formulae.brew.sh').get(`/api/formula/${Tool.Repo}.json`).reply(404);
.get(`/api/formula/${Tool.Repo}.json`)
.reply(404);
await expect(main.run()).rejects.toThrowError(FetchError); await expect(main.run()).rejects.toThrowError(FetchError);
}); });
@ -91,8 +81,6 @@ describe('showVersion()', () => {
}); });
test('return not found', async () => { test('return not found', async () => {
await expect( await expect(main.showVersion('gitgit', ['--version'])).rejects.toThrowError(Error);
main.showVersion('gitgit', ['--version'])
).rejects.toThrowError(Error);
}); });
}); });

View File

@ -27,7 +27,7 @@
} }
}, },
"lint-staged": { "lint-staged": {
"src/**/*.ts": [ "{src,__tests__}/**/*.ts": [
"prettier --check", "prettier --check",
"eslint" "eslint"
], ],

View File

@ -12,11 +12,7 @@ export function getURL(org: string, repo: string, api: string): string {
return url; return url;
} }
export async function getLatestVersion( export async function getLatestVersion(org: string, repo: string, api: string): Promise<string> {
org: string,
repo: string,
api: string
): Promise<string> {
const url = getURL(org, repo, api); const url = getURL(org, repo, api);
const response = await fetch(url); const response = await fetch(url);
const json = await response.json(); const json = await response.json();

View File

@ -1,8 +1,4 @@
export default function getURL( export default function getURL(os: string, extended: string, version: string): string {
os: string,
extended: string,
version: string
): string {
const extendedStr = (extended: string): string => { const extendedStr = (extended: string): string => {
if (extended === 'true') { if (extended === 'true') {
return 'extended_'; return 'extended_';

View File

@ -59,16 +59,10 @@ export async function installer(version: string): Promise<void> {
const toolAssets: string = await tc.downloadTool(toolURL); const toolAssets: string = await tc.downloadTool(toolURL);
let toolBin = ''; let toolBin = '';
if (process.platform === 'win32') { if (process.platform === 'win32') {
const toolExtractedFolder: string = await tc.extractZip( const toolExtractedFolder: string = await tc.extractZip(toolAssets, tempDir);
toolAssets,
tempDir
);
toolBin = `${toolExtractedFolder}/${Tool.CmdName}.exe`; toolBin = `${toolExtractedFolder}/${Tool.CmdName}.exe`;
} else { } else {
const toolExtractedFolder: string = await tc.extractTar( const toolExtractedFolder: string = await tc.extractTar(toolAssets, tempDir);
toolAssets,
tempDir
);
toolBin = `${toolExtractedFolder}/${Tool.CmdName}`; toolBin = `${toolExtractedFolder}/${Tool.CmdName}`;
} }
await io.mv(toolBin, binDir); await io.mv(toolBin, binDir);

View File

@ -9,10 +9,7 @@ export interface ActionResult {
output: string; output: string;
} }
export async function showVersion( export async function showVersion(cmd: string, args: string[]): Promise<ActionResult> {
cmd: string,
args: string[]
): Promise<ActionResult> {
const result: ActionResult = { const result: ActionResult = {
exitcode: 0, exitcode: 0,
output: '' output: ''