Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Factor 'does this program exist?' into a separate method

The tests already reimplement "program_in_path?" so it makes sense to
stop duplicating.
  • Loading branch information...
commit b68296b7aaa76091a54731491400c582f07c4d3b 1 parent 4d737ee
@jordansissel authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 lib/fpm/util.rb
View
13 lib/fpm/util.rb
@@ -45,9 +45,7 @@ def safesystem(*args)
end
program = args[0]
- # Scan path to find the executable
- # Do this to help the user get a better error message.
- if !program.include?("/") and !program_in_path?(program)
+ if !program_exists?(program)
raise ExecutableNotFound.new(program)
end
@@ -79,6 +77,15 @@ def safesystem(*args)
return success
end # def safesystem
+ def program_exists?(program)
+ # Scan path to find the executable
+ # Do this to help the user get a better error message.
+ if !program.include?("/") and !program_in_path?(program)
+ return false
+ end
+ return true
+ end # def program_exists?
+
# Run a command safely in a way that captures output and status.
def safesystemout(*args)
if args.size == 1
Please sign in to comment.
Something went wrong with that request. Please try again.