Module: FerretsOnFire::DSL::ShellDSL
- Included in:
- FerretsOnFire::DSL
- Defined in:
- lib/ferrets_on_fire/dsl/shell_dsl.rb
Instance Method Summary collapse
- #bundle(dir: nil) ⇒ Object
-
#run(cmd, dir: nil, exit_on_failure: true, quiet: false, return_exit_code: false, as: nil, bundler: false, rails_env: nil) ⇒ String
Runs a shell command.
Instance Method Details
#bundle(dir: nil) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/ferrets_on_fire/dsl/shell_dsl.rb', line 2 public def bundle(dir: nil) # Set bundler parallel jobs count if run('sysctl -n hw.ncpu', quiet: true, return_exit_code: true).zero? number_of_cores = run('sysctl -n hw.ncpu', quiet: true).strip.to_i - 1 run("bundle config --global jobs #{number_of_cores}", quiet: true) end run 'bundle', dir: dir, as: 'bundler' end |
#run(cmd, dir: nil, exit_on_failure: true, quiet: false, return_exit_code: false, as: nil, bundler: false, rails_env: nil) ⇒ String
Runs a shell command. Stderr is redirected to Stdout
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ferrets_on_fire/dsl/shell_dsl.rb', line 24 public def run(cmd, dir: nil, exit_on_failure: true, quiet: false, return_exit_code: false, as: nil, bundler: false, rails_env: nil) # Build complete command cmd = build_command(cmd, dir, rails_env, bundler) # Run the command and print the output if wished output, status = execute_shell_cmd(cmd, quiet, as) # Error handling if status.nonzero? && return_exit_code == false crash "Shell command exited with status code #{status}!", output, command: cmd, exit: exit_on_failure end return_exit_code ? status : output end |