Skip to content

Commit

Permalink
fix: resolving kcd-scripts bin
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Sep 20, 2017
1 parent 11e690a commit ec4164e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
9 changes: 0 additions & 9 deletions other/symlink.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"lint": "node src lint",
"format": "node src format",
"validate": "node src validate",
"precommit": "node other/symlink && node src precommit"
"precommit": "node src precommit"
},
"files": ["dist", "babel.js", "eslint.js", "config.js"],
"keywords": [],
Expand Down
4 changes: 2 additions & 2 deletions src/config/lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {resolveBin} = require('../utils')
const {resolveKcdScripts} = require('../utils')

const kcdScripts = resolveBin('kcd-scripts')
const kcdScripts = resolveKcdScripts()

module.exports = {
linters: {
Expand Down
8 changes: 8 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ const {pkg, path: pkgPath} = readPkgUp.sync({
})
const appDirectory = path.dirname(pkgPath)

function resolveKcdScripts() {
if (pkg.name === 'kcd-scripts') {
return require.resolve('./')
}
return resolveBin('kcd-scripts')
}

// eslint-disable-next-line complexity
function resolveBin(modName, {executable = modName} = {}) {
let pathFromWhich
Expand Down Expand Up @@ -111,6 +118,7 @@ module.exports = {
fromRoot,
hasScript,
resolveBin,
resolveKcdScripts,
parseEnv,
pkg,
hasFile,
Expand Down

0 comments on commit ec4164e

Please sign in to comment.