Class: Wordmove::Actions::RunLocalCommand

Inherits:
Object
  • Object
show all
Extended by:
LightService::Action
Includes:
Helpers
Defined in:
lib/wordmove/actions/run_local_command.rb

Overview

Note:

This action is not meant to be organized, but as a standalone one.

Run a command on the local system. Command won’t be run if --simulate flag is present on CLI.

Instance Method Summary collapse

Instance Method Details

#executeLightService::Context

Returns Action’s context.

Parameters:

  • command (String)

    The command to run

  • cli_options (Hash)
  • logger (Wordmove::Logger)

Returns:

  • (LightService::Context)

    Action’s context



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/wordmove/actions/run_local_command.rb', line 21

executed do |context|
  context.logger.task_step true, context.command

  next context if simulate?(cli_options: context.cli_options)

  begin
    system(context.command, exception: true)
  rescue RuntimeError, SystemExit => e
    context.fail!("Local command status reports an error: #{e.message}")
  end
end