Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Jun 24, 2019
1 parent 3434d38 commit dfc991b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 41 deletions.
12 changes: 5 additions & 7 deletions src/installer/__tests__/index.ts
Expand Up @@ -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<string[]> => del(tempDir, { force: true }))

it('should install and uninstall', (): void => {
Expand Down
4 changes: 2 additions & 2 deletions src/installer/index.ts
Expand Up @@ -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)
)
}

Expand Down
20 changes: 8 additions & 12 deletions src/runner/__tests__/index.ts
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions src/runner/bin.ts
Expand Up @@ -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)
})
23 changes: 9 additions & 14 deletions src/upgrader/index.ts
Expand Up @@ -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) {
Expand Down

0 comments on commit dfc991b

Please sign in to comment.