Skip to content

Refactor RunCommand to use execute helper from cli_tools #4439

Closed

Description

@coderabbitai

Description

Refactor RunCommand._executeScript to use the new execute helper function from cli_tools instead of manually managing process execution, signal forwarding, and stdin/stdout/stderr streaming.

Context

The RunCommand._executeScript method in tools/serverpod_cli/lib/src/commands/run.dart currently implements shell command execution with:

  • Shell invocation (bash/cmd)
  • Signal forwarding (SIGINT, SIGTERM)
  • stdin passthrough to child process
  • Real-time stdout/stderr streaming
  • Exit code handling

The cli_tools package now provides an execute helper function (see serverpod/cli_tools#96) that encapsulates all this functionality with proper signal propagation, stdin/stdout/stderr forwarding, and optional working directory support.

Benefits

  • Reduces code duplication by using shared utility
  • Simplifies RunCommand implementation
  • Centralizes shell execution logic in cli_tools
  • Improves maintainability - fixes and improvements to execute benefit all consumers

Implementation

Replace the custom _executeScript implementation with a call to the execute function from cli_tools:

Future<int> _executeScript(Script script, String workingDirectory) async {
  log.info('Running "${script.name}": ${script.command}');
  return execute(script.command, workingDirectory: workingDirectory);
}

Prerequisites

References

Activity

  1. nielsenko commented on Dec 12, 2025

    @nielsenko
    Collaborator

    This requires bumping cli_tools to ^10.0.0, which is the real work in this issue.

  2. moved this from Inbox 📫 to In Progress 🔥 in Serverpod Frameworkson Dec 19, 2025
  3. added
    area: cli
    on Dec 19, 2025
  4. moved this from In Progress 🔥 to Done 🚀 in Serverpod Frameworkson Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: cli

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions