Skip to content

feat: init cli shortcut#453

Merged
9aoy merged 1 commit intomainfrom
cliShortcuts
Aug 7, 2025
Merged

feat: init cli shortcut#453
9aoy merged 1 commit intomainfrom
cliShortcuts

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Aug 7, 2025

Summary

Init cli shortcuts, support c and q shortcuts in watch mode.

image

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings August 7, 2025 06:17
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 7, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit e5d7bcd
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/689444fd3aa80b000815165a
😎 Deploy Preview https://deploy-preview-453--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds CLI shortcut functionality for watch mode in the testing framework, allowing users to interact with the running test process using keyboard shortcuts.

  • Introduces a setupCliShortcuts function that handles keyboard input for interactive commands
  • Adds isTTY utility function to detect terminal environments
  • Integrates CLI shortcuts into the watch mode workflow with support for clearing console and quitting

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/core/src/utils/helper.ts Adds isTTY utility function to check terminal environment
packages/core/src/core/runTests.ts Integrates CLI shortcuts setup into watch mode execution
packages/core/src/core/cliShortcuts.ts Implements the complete CLI shortcuts functionality with keyboard handling


for (const shortcut of shortcuts) {
if (input === shortcut.key) {
shortcut.action();
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shortcut action is not awaited, which could cause issues if the action is async (like the 'q' shortcut). Consider using await shortcut.action(); to ensure proper execution order.

Suggested change
shortcut.action();
await shortcut.action();

Copilot uses AI. Check for mistakes.
try {
await closeServer();
} finally {
process.exit(0);
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using process.exit(0) in a finally block may prevent proper cleanup if closeServer() throws an error. Consider handling the error case separately or using a more graceful shutdown approach.

Suggested change
process.exit(0);
process.exit(0);
} catch (err) {
logger.error('Error while closing server:', err);
process.exit(1);

Copilot uses AI. Check for mistakes.
];

logger.log(
` ${color.dim('press')} ${color.bold('h')} ${color.dim('to show help')}${color.dim(', press')} ${color.bold('q')} ${color.dim('to quit')}\n`,
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help message is hardcoded and doesn't reflect the actual available shortcuts dynamically. Consider generating this message from the shortcuts array to maintain consistency.

Suggested change
` ${color.dim('press')} ${color.bold('h')} ${color.dim('to show help')}${color.dim(', press')} ${color.bold('q')} ${color.dim('to quit')}\n`,
// Dynamically generate the help message from the shortcuts array
const shortcutKeys = shortcuts.map(s => `${color.bold(s.key)}`).join(`${color.dim(', ')} `);
logger.log(
` ${color.dim('press')} ${shortcutKeys} ${color.dim('to use shortcuts, press')} ${color.bold('h')} ${color.dim('to show help')}\n`,

Copilot uses AI. Check for mistakes.
@9aoy 9aoy requested a review from fi3ework August 7, 2025 07:40
@9aoy 9aoy merged commit ab3ed20 into main Aug 7, 2025
18 checks passed
@9aoy 9aoy deleted the cliShortcuts branch August 7, 2025 08:23
@9aoy 9aoy mentioned this pull request Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants