* 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:
di-sukharev
2023-03-10 22:49:27 +08:00
parent 1347962a93
commit 6712e798c5

View File

@@ -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