Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
feat(cz): use commitlint prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Feb 11, 2018
1 parent 8c00ba4 commit 1fcdce1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ process.on('unhandledRejection', err => {
})

const spawn = require('cross-spawn')
const runCommitizen = require('commitizen/dist/cli/git-cz').bootstrap

const { resolveInDir, resolveBin } = require('./resolve-utils')
const { resolveInDir, resolveModule, resolveBin } = require('./resolve-utils')

const CLICargs = process.argv.slice(3)
const runCommand = (command, args, { resolveCommand = true } = {}) => {
Expand Down Expand Up @@ -65,12 +66,16 @@ switch (scriptName) {
])
break
case 'precommit':
runCommand('lint-staged', ['--config', resolveInDir('./.lintstagedrc.js')])
runCommand('yarn', ['run', 'lint'], { resolveCommand: false })
runCommand('yarn', ['test'], { resolveCommand: false })
// runCommand('lint-staged', ['--config', resolveInDir('./.lintstagedrc.js')])
// runCommand('yarn', ['run', 'lint'], { resolveCommand: false })
// runCommand('yarn', ['test'], { resolveCommand: false })
break
case 'cz':
runCommand('git-cz')
process.argv = []
runCommitizen({
cliPath: resolveModule('commitizen'),
config: { path: resolveModule('@commitlint/prompt') }
})
break
default:
console.log('Unknown script "' + scriptName + '".')
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
"commitmsg": "node ./index.js commitmsg",
"cz": "node ./index.js cz"
},
"config": {
"commitizen": {
"path": "@commitlint/prompt"
}
},
"peerDependencies": {
"eslint-plugin-react": "^7.6.1"
},
Expand Down
6 changes: 3 additions & 3 deletions resolve-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { resolve, join } = require('path')

const resolveInDir = filePath => resolve(__dirname, filePath)
const resolveBin = filePath =>
resolveInDir(join('./node_modules/.bin', filePath))
const resolveModule = filePath => resolveInDir(join('./node_modules', filePath))
const resolveBin = filePath => resolveModule(join('./.bin', filePath))

module.exports = { resolveInDir, resolveBin }
module.exports = { resolveInDir, resolveModule, resolveBin }

0 comments on commit 1fcdce1

Please sign in to comment.