View changes in custom Rails generator

50 Views Asked by At

I'd like to view the affected files and/or changes that will be made prior to running a method in my custom Rails generator. I've looked through the docs for days and am beginning to think its not possible.

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

In the example above I'm trying to copy the contents of a template directory into the destination app.

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

Here are the contents of the "mytemplate" directory inside of my gem to give a little context. What I'm hoping to see inside of the generators copy_theme_files_to_app method is either an array of new paths to be generated/destroyed or showing the potential conflict between my template's application.scss file and the one in the app.

Is this possible?

0

There are 0 best solutions below