mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
* feat(cli.ts): add check for new opencommit version after commit is made
* chore(cli.ts): import execa and outro from their respective packages
This commit is contained in:
14
src/cli.ts
14
src/cli.ts
@@ -7,6 +7,8 @@ import { configCommand } from './commands/config';
|
||||
import { hookCommand, isHookCalled } from './commands/githook.js';
|
||||
import { prepareCommitMessageHook } from './commands/prepare-commit-msg-hook';
|
||||
import { commit } from './commands/commit';
|
||||
import { execa } from 'execa';
|
||||
import { outro } from '@clack/prompts';
|
||||
|
||||
const rawArgv = process.argv.slice(2);
|
||||
|
||||
@@ -19,11 +21,17 @@ cli(
|
||||
ignoreArgv: (type) => type === 'unknown-flag' || type === 'argument',
|
||||
help: { description: packageJSON.description }
|
||||
},
|
||||
() => {
|
||||
async () => {
|
||||
if (isHookCalled) {
|
||||
prepareCommitMessageHook();
|
||||
await prepareCommitMessageHook();
|
||||
} else {
|
||||
commit();
|
||||
await commit();
|
||||
const { stdout } = await execa('npm', ['view', 'opencommit', 'version']);
|
||||
|
||||
if (stdout !== packageJSON.version)
|
||||
outro(
|
||||
'new opencommit version is available, update with `npm i -g opencommit`'
|
||||
);
|
||||
}
|
||||
},
|
||||
rawArgv
|
||||
|
||||
Reference in New Issue
Block a user