Sha256: 4e0b2387a09b3be0b8de6f915d69e80f74fe9786e7e7db3877f8d79699fcd15c

Contents?: true

Size: 1.09 KB

Versions: 13

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true
module Lono
  # Checks to see command is running in a lono project.
  # If not, provide a friendly message and possibly exit.
  class ProjectChecker
    class << self
      def check
        check_lono_project
      end

      def check_lono_project
        paths = %w[
          config/settings.yml
          app/definitions
          app/templates
        ]
        paths.each do |path|
          unless File.exist?("#{Lono.root}/#{path}")
            puts "ERROR: The #{path} does not exist in this project.  Are you sure you are in lono project?".colorize(:red)
            quit 1
          end
        end
      end

      # Dont exit for this one. It's okay. But show a warning.
      def empty_templates
        if Dir["#{Lono.config.templates_path}/**/*"].empty?
          puts "INFO: The app/templates folder does not contain any lono template definitions.".colorize(:yellow)
        end
      end

      def quit(signal)
        if ENV['TEST'] == '1'
          signal == 0 || raise("Not in lono project")
        else
          exit(signal)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
lono-4.2.4 lib/lono/project_checker.rb
lono-4.2.3 lib/lono/project_checker.rb
lono-4.2.2 lib/lono/project_checker.rb
lono-4.2.1 lib/lono/project_checker.rb
lono-4.2.0 lib/lono/project_checker.rb
lono-4.1.0 lib/lono/project_checker.rb
lono-4.0.6 lib/lono/project_checker.rb
lono-4.0.5 lib/lono/project_checker.rb
lono-4.0.4 lib/lono/project_checker.rb
lono-4.0.3 lib/lono/project_checker.rb
lono-4.0.2 lib/lono/project_checker.rb
lono-4.0.1 lib/lono/project_checker.rb
lono-4.0.0 lib/lono/project_checker.rb