|
1 | | -// import commits from 'git-raw-commits'; |
2 | 1 | import meow from 'meow'; |
3 | 2 | import showNotifications from './showNotifications'; |
4 | | -import { Lifecycle, Flags } from './types'; |
5 | 3 | import { getLogStream } from './git'; |
6 | | - |
7 | | -async function hook(lifecycle: Lifecycle, args: string[], flags: Flags) { |
8 | | - // get all commit messages for the relevant revision range |
9 | | - // depending on which git hook / command was executed |
10 | | - const logs = await getLogStream(lifecycle, args); |
11 | | - |
12 | | - // stream through logs and print any found notifications |
13 | | - showNotifications(logs, flags); |
14 | | -} |
| 4 | +import { Lifecycle, Flags } from './types'; |
15 | 5 |
|
16 | 6 | const cli = meow( |
17 | 7 | ` |
@@ -60,4 +50,19 @@ const cli = meow( |
60 | 50 | } |
61 | 51 | ); |
62 | 52 |
|
63 | | -hook(cli.input[0] as Lifecycle, cli.input.slice(1), cli.flags); |
| 53 | +async function hook(lifecycle: Lifecycle, args: string[], flags: Flags) { |
| 54 | + // get all commit messages for the relevant revision range |
| 55 | + // depending on which git hook / command was executed |
| 56 | + const logs = await getLogStream(lifecycle, args); |
| 57 | + |
| 58 | + // stream through logs and print any found notifications |
| 59 | + showNotifications(logs, flags); |
| 60 | +} |
| 61 | + |
| 62 | +// first argument is the git hook method |
| 63 | +const lifecycle = cli.input[0] as Lifecycle; |
| 64 | + |
| 65 | +// rest of the positional args come from the git hook |
| 66 | +const gitHookArgs = cli.input.slice(1); |
| 67 | + |
| 68 | +hook(lifecycle, gitHookArgs, cli.flags); |
0 commit comments