From c363677ebabe744393be43435d584b816d5bb67b Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Fri, 19 Jan 2018 14:37:25 -0800 Subject: [PATCH] feat: added hook --- package.json | 5 ++++- src/hooks/init.ts | 13 +++++++++++++ src/index.ts | 1 + tsconfig.json | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/hooks/init.ts create mode 100644 src/index.ts diff --git a/package.json b/package.json index e1fc1fd..1c32068 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/hooks/init.ts b/src/hooks/init.ts new file mode 100644 index 0000000..108668f --- /dev/null +++ b/src/hooks/init.ts @@ -0,0 +1,13 @@ +import {Hooks, IHook} from '@dxcli/config' +import cli from 'cli-ux' + +import Version from '../commands/version' + +const hook: IHook = async opts => { + if (['-v', '--version'].includes(opts.id)) { + await Version.run([], opts) + cli.exit(0) + } +} + +export default hook diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..b1c6ea4 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export default {} diff --git a/tsconfig.json b/tsconfig.json index 59a5cb4..f42b8f4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,9 @@ "noUnusedLocals": true, "noUnusedParameters": true, "outDir": "./lib", - "rootDir": "./src", + "rootDirs": [ + "./src" + ], "strict": true, "target": "es2017" },