Skip to content

Commit

Permalink
feat: added hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 19, 2018
1 parent b8462b1 commit c363677
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
"typescript": "^2.6.2"
},
"dxcli": {
"commands": "./lib/commands"
"commands": "./lib/commands",
"hooks": {
"init": "./lib/hooks/init"
}
},
"engines": {
"node": ">=8.0.0"
Expand Down
13 changes: 13 additions & 0 deletions src/hooks/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {Hooks, IHook} from '@dxcli/config'
import cli from 'cli-ux'

import Version from '../commands/version'

const hook: IHook<Hooks['init']> = async opts => {
if (['-v', '--version'].includes(opts.id)) {
await Version.run([], opts)
cli.exit(0)
}
}

export default hook
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {}
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./lib",
"rootDir": "./src",
"rootDirs": [
"./src"
],
"strict": true,
"target": "es2017"
},
Expand Down

0 comments on commit c363677

Please sign in to comment.