Sha256: 5e2267b2f55c03f9a52cb22b94fa44093f23d54520751ab3d9eaff021a4331ee
Contents?: true
Size: 1.09 KB
Versions: 11
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Bundler class CLI::Init attr_reader :options def initialize(options) @options = options end def run if File.exist?(gemfile) Bundler.ui.error "#{gemfile} already exists at #{File.expand_path(gemfile)}" exit 1 end if options[:gemspec] gemspec = File.expand_path(options[:gemspec]) unless File.exist?(gemspec) Bundler.ui.error "Gem specification #{gemspec} doesn't exist" exit 1 end spec = Bundler.load_gemspec_uncached(gemspec) File.open(gemfile, "wb") do |file| file << "# Generated from #{gemspec}\n" file << spec.to_gemfile end else FileUtils.cp(File.expand_path("../../templates/#{gemfile}", __FILE__), gemfile) end puts "Writing new #{gemfile} to #{SharedHelpers.pwd}/#{gemfile}" end private def gemfile @gemfile ||= begin Bundler.default_gemfile rescue GemfileNotFound Bundler.feature_flag.init_gems_rb? ? "gems.rb" : "Gemfile" end end end end
Version data entries
11 entries across 11 versions & 3 rubygems