1

我想查看受影响的文件和/或在我的自定义 Rails 生成器中运行方法之前将进行的更改。我已经看了好几天的文档,开始认为这是不可能的。

module Mygem
  module Generators
    class InstallGenerator < Rails::Generators::Base

      source_root File.expand_path('../templates', __FILE__)

      def copy_theme_files_to_app
        directory( source_paths[0] + "/mytemplate", Dir.pwd)
      end

    end
  end
end

在上面的示例中,我试图将模板目录的内容复制到目标应用程序中。

├── lib
│   ├── generators
│   │   ├── mygem
│   │   │   ├── templates
│   │   │   │   ├── mytemplate
│   │   │   │   │   ├── app
│   │   │   │   │   │   ├── assets
│   │   │   │   │   │   │   ├── stylesheets
│   │   │   │   │   │   │   │   ├── application.scss
│   │   │   │   │   │   │   │   ├── custom.scss

以下是我的 gem 中的“mytemplate”目录的内容,以提供一些背景信息。我希望在生成器copy_theme_files_to_app方法内部看到的是要生成/销毁的一组新路径,或者显示模板的 application.scss 文件与应用程序中的文件之间的潜在冲突。

这可能吗?

4

0 回答 0