【问题标题】:Running Rake::Pipeline.build inside of Rakefile在 Rakefile 中运行 Rake::Pipeline.build
【发布时间】:2013-08-12 18:21:10
【问题描述】:

我正在尝试从 Rakefile 中启动 Rake Pipeline 任务。据我所知,要执行此操作的过程将是执行example here 之类的操作。

但是,这不起作用。这是减少example to barebones 的要点。

它显示了一个简化的测试用例,它使用 rake-pipeline 的 Assetfile 工作,但是当尝试在 Rakefile 中包含相同的确切代码时它不起作用。

  1. 为什么会失败?
  2. 有什么解决方案可以完成这项工作? (作为 Rakefile 的一部分,没有作弊和运行系统调用。)

感谢您的帮助!

【问题讨论】:

    标签: ruby rake rake-pipeline


    【解决方案1】:

    作品

    看起来处理这个问题的一种方法是执行一个文件,如下所示:

    project = Rake::Pipeline::Project.new('Assetfile')
    # project.clean      # Required for rake-pipeline 0.7.0
    project.invoke
    

    但是,这很烦人,因为我必须为每个 rake 任务创建一个文件。

    不工作

    Looking at the code for Rake::Pipeline 它应该允许我传入管道,这样代码才能正常工作:

    pipeline = Rake::Pipeline.build do
      output "js"
      puts Dir.pwd
      input "js" do
        match "*.js" do
          # concatenate all JS files into a single file
          filter Rake::Pipeline::ConcatFilter, "application.js"
        end
      end
    end
    
    project = Rake::Pipeline::Project.new(pipeline)
    project.invoke
    

    有人知道为什么这不起作用吗?错误:

    undefined method `manifest' for nil:NilClass
    rake-pipeline-0.8.0/lib/rake-pipeline.rb:408:in `manifest'
    rake-pipeline-0.8.0/lib/rake-pipeline.rb:456:in `block in record_input_files'
    rake-pipeline-0.8.0/lib/rake-pipeline.rb:453:in `each'
    rake-pipeline-0.8.0/lib/rake-pipeline.rb:453:in `record_input_files'
    rake-pipeline-0.8.0/lib/rake-pipeline.rb:340:in `setup'
    rake-pipeline-0.8.0/lib/rake-pipeline.rb:326:in `block in invoke'
    <internal:prelude>:10:in `synchronize'
    rake-pipeline-0.8.0/lib/rake-pipeline.rb:321:in `invoke'
    rake-pipeline-0.8.0/lib/rake-pipeline/project.rb:126:in `each'
    rake-pipeline-0.8.0/lib/rake-pipeline/project.rb:126:in `block in invoke'
    <internal:prelude>:10:in `synchronize'
    rake-pipeline-0.8.0/lib/rake-pipeline/project.rb:112:in `invoke'
    Rakefile:23:in `block in <top (required)>'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-14
      • 2019-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-23
      • 2011-05-29
      • 1970-01-01
      相关资源
      最近更新 更多