From dfc991b426406f690d6bffd51a211e9407f7b080 Mon Sep 17 00:00:00 2001 From: typicode Date: Mon, 24 Jun 2019 13:49:09 +0200 Subject: [PATCH] prettier --- src/installer/__tests__/index.ts | 12 +++++------- src/installer/index.ts | 4 ++-- src/runner/__tests__/index.ts | 20 ++++++++------------ src/runner/bin.ts | 10 ++++------ src/upgrader/index.ts | 23 +++++++++-------------- 5 files changed, 28 insertions(+), 41 deletions(-) diff --git a/src/installer/__tests__/index.ts b/src/installer/__tests__/index.ts index 0ec60a1b0..a4246349f 100644 --- a/src/installer/__tests__/index.ts +++ b/src/installer/__tests__/index.ts @@ -73,13 +73,11 @@ function expectHookToExist(filename: string): void { // Tests describe('install', (): void => { - beforeEach( - (): void => { - delete process.env.INIT_CWD - delete process.env.HUSKY_SKIP_INSTALL - tempDir = tempy.directory() - } - ) + beforeEach((): void => { + delete process.env.INIT_CWD + delete process.env.HUSKY_SKIP_INSTALL + tempDir = tempy.directory() + }) afterEach((): Promise => del(tempDir, { force: true })) it('should install and uninstall', (): void => { diff --git a/src/installer/index.ts b/src/installer/index.ts index 43e74f428..ac881d974 100644 --- a/src/installer/index.ts +++ b/src/installer/index.ts @@ -102,8 +102,8 @@ function isInNodeModules(dir: string): boolean { function getHooks(gitDir: string): string[] { const gitHooksDir = path.join(gitDir, 'hooks') - return hookList.map( - (hookName: string): string => path.join(gitHooksDir, hookName) + return hookList.map((hookName: string): string => + path.join(gitHooksDir, hookName) ) } diff --git a/src/runner/__tests__/index.ts b/src/runner/__tests__/index.ts index 7874ee32f..92666ccd1 100644 --- a/src/runner/__tests__/index.ts +++ b/src/runner/__tests__/index.ts @@ -12,18 +12,14 @@ function getScriptPath(dir: string): string { } describe('run', (): void => { - beforeEach( - (): void => { - spy = jest.spyOn(execa, 'shellSync') - } - ) - - afterEach( - (): void => { - spy.mockReset() - spy.mockRestore() - } - ) + beforeEach((): void => { + spy = jest.spyOn(execa, 'shellSync') + }) + + afterEach((): void => { + spy.mockReset() + spy.mockRestore() + }) it('should run working command and return 0 status', async (): Promise< void diff --git a/src/runner/bin.ts b/src/runner/bin.ts index 8987fc18a..f9a8ece17 100644 --- a/src/runner/bin.ts +++ b/src/runner/bin.ts @@ -7,9 +7,7 @@ debug(`CWD=${process.env.CWD}`) // Run hook index(process.argv) .then((status: number): void => process.exit(status)) - .catch( - (err: Error): void => { - console.log('Husky > unexpected error', err) - process.exit(1) - } - ) + .catch((err: Error): void => { + console.log('Husky > unexpected error', err) + process.exit(1) + }) diff --git a/src/upgrader/index.ts b/src/upgrader/index.ts index 748a66558..668591e54 100644 --- a/src/upgrader/index.ts +++ b/src/upgrader/index.ts @@ -45,22 +45,17 @@ export default function upgrade(cwd: string): void { const hooks: HookMap = {} // Find hooks in package.json 'scripts' field - Object.keys(hookList).forEach( - (name: string): void => { - if (pkg.scripts) { - const script = pkg.scripts[name] - if (script) { - delete pkg.scripts[name] - const newName = hookList[name] - hooks[newName] = script.replace( - /\bGIT_PARAMS\b/g, - 'HUSKY_GIT_PARAMS' - ) - console.log(`moved scripts.${name} to husky.hooks.${newName}`) - } + Object.keys(hookList).forEach((name: string): void => { + if (pkg.scripts) { + const script = pkg.scripts[name] + if (script) { + delete pkg.scripts[name] + const newName = hookList[name] + hooks[newName] = script.replace(/\bGIT_PARAMS\b/g, 'HUSKY_GIT_PARAMS') + console.log(`moved scripts.${name} to husky.hooks.${newName}`) } } - ) + }) // Move found hooks to 'husky.hooks' field if (Object.keys(hooks).length) {