Browse files

Properly make the args ordering be $HOME/.fpm, $PWD/.fpm, CLI args

This fixes #615

    % cat .fpm
    --maintainer "Hello"
    % fpm -s dir -t rpm -n fizzle ~/.zshrc
    Loading flags from rc file .fpm {:level=>:warn}
    {:args=>["--maintainer", "Hello", "-s", "dir", "-t", "rpm", "-n", "fizzle", "/home/jls/.zshrc"]}
    no value for epoch is set, defaulting to nil {:level=>:warn}
    File already exists, refusing to continue: fizzle-1.0-1.x86_64.rpm
    % rpm -qip fizzle-1.0-1.x86_64.rpm| grep Packager
    Packager    : Hello
  • Loading branch information...
1 parent 9688896 commit 1f764b8dad58d657397f3bca742039fafadf1823 @jordansissel committed Jan 7, 2014
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/fpm/command.rb
@@ -420,14 +420,18 @@ def run(*args)
# fpm initialization files, note the order of the following array is
# important, try .fpm in users home directory first and then the current
# directory
- rc_files = [File.join(ENV['HOME'],'.fpm'), '.fpm']
+ rc_files = [ ".fpm" ]
+ rc_files << File.join(ENV["HOME"], ".fpm") if ENV["HOME"]
rc_files.each do |rc_file|
if File.readable? rc_file
@logger.warn("Loading flags from rc file #{rc_file}")
File.readlines(rc_file).each do |line|
- Shellwords.shellsplit(line).each do |e|
- ARGV << e
+ # reverse becasue 'unshift' pushes onto the left side of the array.
+ Shellwords.shellsplit(line).reverse.each do |arg|
+ # Put '.fpm'-file flags *before* the command line flags
+ # so that we the CLI can override the .fpm flags
+ ARGV.unshift(arg)

0 comments on commit 1f764b8

Please sign in to comment.