* 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:
+11
-3
@@ -7,6 +7,8 @@ import { configCommand } from './commands/config';
|
|||||||
import { hookCommand, isHookCalled } from './commands/githook.js';
|
import { hookCommand, isHookCalled } from './commands/githook.js';
|
||||||
import { prepareCommitMessageHook } from './commands/prepare-commit-msg-hook';
|
import { prepareCommitMessageHook } from './commands/prepare-commit-msg-hook';
|
||||||
import { commit } from './commands/commit';
|
import { commit } from './commands/commit';
|
||||||
|
import { execa } from 'execa';
|
||||||
|
import { outro } from '@clack/prompts';
|
||||||
|
|
||||||
const rawArgv = process.argv.slice(2);
|
const rawArgv = process.argv.slice(2);
|
||||||
|
|
||||||
@@ -19,11 +21,17 @@ cli(
|
|||||||
ignoreArgv: (type) => type === 'unknown-flag' || type === 'argument',
|
ignoreArgv: (type) => type === 'unknown-flag' || type === 'argument',
|
||||||
help: { description: packageJSON.description }
|
help: { description: packageJSON.description }
|
||||||
},
|
},
|
||||||
() => {
|
async () => {
|
||||||
if (isHookCalled) {
|
if (isHookCalled) {
|
||||||
prepareCommitMessageHook();
|
await prepareCommitMessageHook();
|
||||||
} else {
|
} 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
|
rawArgv
|
||||||
|
|||||||
Reference in New Issue
Block a user