Skip to content

Commit 70cf1fc

Browse files
committed
pre-commit script
1 parent 1f5ecca commit 70cf1fc

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
"private": true,
44
"devDependencies": {
55
"lerna": "^3.5.1"
6+
},
7+
"husky": {
8+
"hooks": {
9+
"pre-commit": ""
10+
}
611
}
712
}

packages/more/bin/more.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ process.on('unhandledRejection', err => {
1010
const spawn = require('cross-spawn')
1111
const args = process.argv.slice(2)
1212

13-
const scriptIndex = args.findIndex(x => x === 'build' || x === 'start')
13+
const commands = ['build', 'start', 'pre-commit']
14+
15+
const scriptIndex = args.findIndex(x => commands.includes(x))
1416

1517
const script = scriptIndex === -1 ? args[0] : args[scriptIndex]
1618
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []
1719

1820
switch (script) {
21+
case 'pre-commit':
1922
case 'build':
2023
case 'start': {
2124
const result = spawn.sync(

packages/more/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"husky": {
5050
"hooks": {
51-
"pre-commit": "lint-staged"
51+
"pre-commit": "./bin/more.js pre-commit"
5252
}
5353
},
5454
"prettier": {

packages/more/scripts/pre-commit.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('lint-staged')

0 commit comments

Comments
 (0)