How do I make a Rake Task run after all other tasks? (i.e. a Rake AfterBuild task)

前端 未结 7 981
感动是毒
感动是毒 2021-02-02 12:39

I\'m new to Rake and using it to build .net projects. What I\'m interested in is having a Summary task that prints out a summary of what has been done. I want this task to alw

7条回答
  •  野性不改
    2021-02-02 13:19

    You could use the Kernel.trap call and attach to the "Exit" signal. It will fire upon both normal and abnormal exit.

    Put this early in your rakefile:

    Kernel.trap("EXIT") do
      Rake::Task[:final].invoke
    end
    

    Now any time you make a "final" task it will be executed at the very end of the program. no matter what.

    task :final do
      puts "Hit return to continue..."
      STDIN.getc
    end
    

提交回复
热议问题