Skip to content

Commit

Permalink
Fix TypeScript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Oct 1, 2018
1 parent 2242913 commit ec415c6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 13 deletions.
34 changes: 33 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -60,6 +60,7 @@
"slash": "^2.0.0"
},
"devDependencies": {
"@types/del": "^3.0.1",
"@types/execa": "^0.9.0",
"@types/find-up": "^2.1.1",
"@types/get-stdin": "^5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/installer/__tests__/index.ts
Expand Up @@ -7,7 +7,7 @@ import * as tempy from 'tempy'
import { install, uninstall } from '../'
import { huskyIdentifier } from '../getScript'

let tempDir
let tempDir: string

const pkg = JSON.stringify({})

Expand Down Expand Up @@ -236,7 +236,7 @@ describe('install', () => {
writeFile('package.json', pkg)

installFrom(huskyDir)
expect(exists('.git/hooks/pre-commit')).toBeFalsy()
expect(exists(hookFilename)).toBeFalsy()
})

it('should migrate existing scripts (ghooks)', () => {
Expand Down
18 changes: 9 additions & 9 deletions src/runner/__tests__/index.ts
Expand Up @@ -5,9 +5,9 @@ import * as path from 'path'
import * as tempy from 'tempy'
import index from '../'

let spy
let spy: jest.SpyInstance

function getScriptPath(dir) {
function getScriptPath(dir: string) {
return path.join(dir, 'node_modules/husky/runner/index.js')
}

Expand Down Expand Up @@ -35,7 +35,7 @@ describe('run', () => {
})
)

const status = await index([, getScriptPath(dir), 'pre-commit'])
const status = await index(['', getScriptPath(dir), 'pre-commit'])
expect(execa.shellSync).toHaveBeenCalledWith('echo success', {
cwd: dir,
env: {},
Expand All @@ -60,7 +60,7 @@ describe('run', () => {
})
)

const status = await index([, getScriptPath(subDir), 'pre-commit'])
const status = await index(['', getScriptPath(subDir), 'pre-commit'])
expect(execa.shellSync).toHaveBeenCalledWith('echo success', {
cwd: subDir,
env: {},
Expand All @@ -81,7 +81,7 @@ describe('run', () => {
})
)

const status = await index([, getScriptPath(dir), 'pre-commit'])
const status = await index(['', getScriptPath(dir), 'pre-commit'])
expect(execa.shellSync).not.toBeCalled()
expect(status).toBe(0)
})
Expand All @@ -100,7 +100,7 @@ describe('run', () => {
})
)

const status = await index([, getScriptPath(dir), 'pre-commit'])
const status = await index(['', getScriptPath(dir), 'pre-commit'])
expect(execa.shellSync).toHaveBeenCalledWith('echo fail && exit 2', {
cwd: dir,
env: {},
Expand All @@ -121,7 +121,7 @@ describe('run', () => {
})
)

const status = await index([, getScriptPath(dir), 'pre-commit'])
const status = await index(['', getScriptPath(dir), 'pre-commit'])
expect(execa.shellSync).toHaveBeenCalledWith('echo success', {
cwd: dir,
env: {},
Expand All @@ -144,7 +144,7 @@ describe('run', () => {
})
)

const status = await index([, getScriptPath(dir), 'pre-push'], () =>
const status = await index(['', getScriptPath(dir), 'pre-push'], () =>
Promise.resolve('foo')
)
expect(execa.shellSync).toHaveBeenCalledWith('echo success', {
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('run', () => {

// commit-msg takes one parameter from git
const status = await index([
,
'',
getScriptPath(dir),
'commit-msg',
'git fake param'
Expand Down
2 changes: 1 addition & 1 deletion src/runner/index.ts
Expand Up @@ -14,7 +14,7 @@ export interface IEnv extends NodeJS.ProcessEnv {
*/
export default async function run(
[, scriptPath, hookName = '', HUSKY_GIT_PARAMS]: string[],
getStdinFn = getStdin // Used for mocking
getStdinFn: () => Promise<string> = getStdin // Used for mocking
): Promise<number> {
const cwd = path.resolve(scriptPath.split('node_modules')[0])
const pkg = readPkg.sync({ cwd, normalize: false })
Expand Down

0 comments on commit ec415c6

Please sign in to comment.