Method: FPM::Command#run
- Defined in:
- lib/fpm/command.rb
#run(run_args) ⇒ Object
def execute
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/fpm/command.rb', line 524 def run(run_args) logger.subscribe(STDOUT) # Short circuit for a `fpm --version` or `fpm -v` short invocation that # is the user asking us for the version of fpm. if run_args == [ "-v" ] || run_args == [ "--version" ] puts FPM::VERSION return 0 end # 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 = [ ".fpm" ] rc_files << File.join(ENV["HOME"], ".fpm") if ENV["HOME"] rc_args = [] if ENV["FPMOPTS"] logger.warn("Loading flags from FPMOPTS environment variable") rc_args.push(*Shellwords.shellsplit(ENV["FPMOPTS"])) end rc_files.each do |rc_file| if File.readable? rc_file logger.warn("Loading flags from rc file #{rc_file}") rc_args.push(*Shellwords.shellsplit(File.read(rc_file))) end end flags = [] args = [] while rc_args.size > 0 do arg = rc_args.shift opt = self.class.find_option(arg) if opt and not opt.flag? flags.push(arg) flags.push(rc_args.shift) elsif opt or arg[0] == "-" flags.push(arg) else args.push(arg) end end logger.warn("Additional options: #{flags.join " "}") if flags.size > 0 logger.warn("Additional arguments: #{args.join " "}") if args.size > 0 ARGV.unshift(*flags) ARGV.push(*args) super(run_args) rescue FPM::Package::InvalidArgument => e logger.error("Invalid package argument: #{e}") return 1 end |