Skip to content

Commit

Permalink
- If no args are given, assume '.' was intended if the source is 'dir'
Browse files Browse the repository at this point in the history
  and chdir (-C) is set. Fixes issue jordansissel#187
- Abort if there's no package name known.
  • Loading branch information
jordansissel committed Mar 30, 2012
1 parent 77fc4a9 commit c8e2657
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/fpm/command.rb
Expand Up @@ -183,6 +183,15 @@ def execute
@logger.subscribe(STDOUT)
@logger.level = :warn

# Some older behavior, if you specify:
# 'fpm -s dir -t ... -C somepath'
# fpm would assume you meant to add '.' to the end of the commandline.
# Let's hack that. https://github.com/jordansissel/fpm/issues/187
if input_type == "dir" and args.empty? and !chdir.nil?
@logger.info("No args, but -s dir and -C are given, assuming '.' as input")
args << "."
end

validator = Validator.new(self)
if !validator.ok?
validator.messages.each do |message|
Expand Down Expand Up @@ -288,7 +297,7 @@ def execute

# 'self.send(scriptname) == self.before_install == --before-install
if !File.exists?(path)
$stderr.puts("No such file (for #{scriptname.to_s}): #{path.inspect}")
@logger.error("No such file (for #{scriptname.to_s}): #{path.inspect}")
return 1
end
input.scripts[scriptname] = File.read(path)
Expand All @@ -299,6 +308,13 @@ def execute
setscript.call(:before_remove)
setscript.call(:after_remove)

# Validate the package
if input.name.nil? or input.name.empty?
@logger.fatal("No name given for this package (set name with, " \
"for example, '-n packagename')")
return 1
end

# Convert to the output type
output = input.convert(output_class)

Expand Down

0 comments on commit c8e2657

Please sign in to comment.