-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So we can reuse them in other places
- Loading branch information
Showing
4 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
# module to encapsulate helpers | ||
module Baes::Helpers | ||
end | ||
|
||
require_relative "helpers/commands" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
# module to encapsulate shell commands | ||
module Baes::Helpers::Commands | ||
# run command and raise error on failure | ||
def run_or_raise(command) | ||
stdout, stderr, status = Open3.capture3(command) | ||
|
||
unless status.success? | ||
output.puts(stderr) | ||
|
||
raise Baes::Git::GitError, "failed to run '#{command}'" | ||
end | ||
|
||
stdout.strip | ||
end | ||
|
||
# run command and return status | ||
def run_returning_status(command) | ||
stdout, stderr, status = Open3.capture3(command) | ||
|
||
output.puts(stdout) | ||
output.puts(stderr) unless stderr.empty? | ||
|
||
status | ||
end | ||
end |