New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance improvements #1108
Labels
Comments
Using dynamic imports might result in some easy wins for the initial startup.
diff --git a/src/cli.js b/src/cli.js
index 4982d27..4aba009 100755
--- a/src/cli.js
+++ b/src/cli.js
@@ -6,7 +6,6 @@ import { readFileSync } from 'fs'
import FLAGS from '@constants/flags'
import findGitmojiCommand from '@utils/findGitmojiCommand'
-import commands from './commands'
const packageJson: Object = readFileSync(
new URL('../package.json', import.meta.url)
@@ -56,14 +55,18 @@ const cli = meow(
)
export const options = ({
- [FLAGS.COMMIT]: (options: Object) => commands.commit(options),
- [FLAGS.CONFIG]: () => commands.config(),
- [FLAGS.HOOK]: (options: Object) => commands.commit(options),
- [FLAGS.INIT]: () => commands.createHook(),
- [FLAGS.LIST]: () => commands.list(),
- [FLAGS.REMOVE]: () => commands.removeHook(),
- [FLAGS.SEARCH]: (options: Object) => commands.search(options),
- [FLAGS.UPDATE]: () => commands.update()
+ [FLAGS.COMMIT]: async (options: Object) =>
+ (await import('./commands/commit')).default(options),
+ [FLAGS.CONFIG]: async () => (await import('./commands/config')).default(),
+ [FLAGS.HOOK]: async (options: Object) =>
+ (await import('./commands/commit')).default(options),
+ [FLAGS.INIT]: async () => (await import('./commands/hook')).default.create(),
+ [FLAGS.LIST]: async () => (await import('./commands/list')).default(),
+ [FLAGS.REMOVE]: async () =>
+ (await import('./commands/hook')).default.remove(),
+ [FLAGS.SEARCH]: async (options: Object) =>
+ (await import('./commands/search')).default(options),
+ [FLAGS.UPDATE]: async () => (await import('./commands/update')).default()
}: { [$Values<typeof FLAGS>]: Function })
findGitmojiCommand(cli, options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Hey! 👋🏼
Our cli can be improved when running and executing commands. In some scenarios and depending on the operating system some commands can take up to 1s to give some output.
See: #1096
Reproduction
This can be reproduced using the time command:
As a result you'll get an output with the seconds each operation take to complete (for the given commands you'll get something like:
Additional context
We should explore the cli to understand if we can apply any improvements that impact the overall time commands take to complete.
System Info
Validations
The text was updated successfully, but these errors were encountered: