Skip to content

Commit

Permalink
fix(lintstaged): fix utils to resolve to itpReactScripts when used ex…
Browse files Browse the repository at this point in the history
…ternally
  • Loading branch information
Jonathan Dierckens committed Aug 26, 2018
1 parent 9da5fea commit d693a77
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/__tests__/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ test('resolveItpReactScripts resolves to src/index.js when in the @inthepocket/i
)
})

test('resolveItpReactScripts resolves to @inthepocket/itp-react-scripts if not in the itp-react-scripts package', () => {
test('resolveItpReactScripts resolves to itp-react-scripts if not in the @inthepocket/itp-react-scripts package', () => {
mockPkg({pkg: {name: 'not-itp-react-scripts'}})
whichSyncMock.mockImplementationOnce(() => require.resolve('../'))
expect(require('../utils').resolveItpReactScripts()).toBe(
'@inthepocket/itp-react-scripts',
)
expect(require('../utils').resolveItpReactScripts()).toBe('itp-react-scripts')
})

test(`resolveBin resolves to the full path when it's not in $PATH`, () => {
Expand Down
10 changes: 5 additions & 5 deletions src/config/lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const {resolveItpReactScripts, resolveBin, isOptedOut} = require('../utils')

const kcdScripts = resolveItpReactScripts()
const itpScripts = resolveItpReactScripts()
const doctoc = resolveBin('doctoc')

module.exports = {
concurrent: false,
linters: {
'README.md': [`${doctoc} --maxlevel 3 --notitle`, 'git add'],
'.all-contributorsrc': [
`${kcdScripts} contributors generate`,
`${itpScripts} contributors generate`,
'git add README.md',
],
'**/*.+(js|json|less|css|ts|tsx|md)': [
isOptedOut('autoformat', null, `${kcdScripts} format`),
`${kcdScripts} lint`,
`${kcdScripts} test --findRelatedTests --passWithNoTests`,
isOptedOut('autoformat', null, `${itpScripts} format`),
`${itpScripts} lint`,
`${itpScripts} test --findRelatedTests --passWithNoTests`,
isOptedOut('autoformat', null, 'git add'),
].filter(Boolean),
},
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function resolveItpReactScripts() {
if (pkg.name === '@inthepocket/itp-react-scripts') {
return require.resolve('./').replace(process.cwd(), '.')
}
return resolveBin('@inthepocket/itp-react-scripts')
return resolveBin('itp-react-scripts')
}

// eslint-disable-next-line complexity
Expand Down

0 comments on commit d693a77

Please sign in to comment.