Sha256: 5c6ee388bac14637be0938e908ca06fd744c3752f0fd8bd8dcef6283983f46db

Contents?: true

Size: 1.96 KB

Versions: 2

Compression:

Stored size: 1.96 KB

Contents

class Updater
  module Scss
    def update_scss_assets
      log_status 'Updating scss...'
      save_to = @save_to[:scss]
      contents = {}
      bootstrap_scss_files = get_paths_by_type('scss', /\.scss$/)
      read_files('scss', bootstrap_scss_files).each do |name, file|
        contents[name] = file
        save_file("#{save_to}/#{name}", file)
      end
      log_processed "#{bootstrap_scss_files * ' '}"

      log_status 'Updating scss main files'
      %w(bootstrap bootstrap-flex bootstrap-grid bootstrap-reboot).each do |name|
        # Compass treats non-partials as targets to copy into the main project, so make them partials.
        # Also move them up a level to clearly indicate entry points.
        from = "#{save_to}/#{name}.scss"
        to   = "#{save_to}/../_#{name}.scss"
        FileUtils.mv from, to
        # As we moved the files, adjust imports accordingly (except for bootstrap-flex that imports the main bootstrap).
        unless 'bootstrap-flex' == name
          File.write to, File.read(to).gsub(/ "/, ' "bootstrap/')
        end
      end

      log_status 'Generating variable template file'
      save_file 'templates/project/_bootstrap-variables.scss',
                "// Override Bootstrap variables here (defaults from bootstrap v#{upstream_version}):\n" +
                    File.read("#{save_to}/_variables.scss").
                        # The instructions in the file header are replaced with the line above
                        lines[4..-1].
                        # Remove the _assert-ascending mixin definition and usages
                        reject { |line| line.start_with?('@include _assert-ascending') }.
                        join.
                        gsub(/@mixin _assert-ascending.*?\n}\n/m, '').
                        # Comment out the assignments
                        gsub(/^(?=\$|\)|[ ]{2})/, '// ').
                        # Remove the !default modifier
                        gsub(/ !default/, '')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bootstrap-4.0.0.alpha5 tasks/updater/scss.rb
bootstrap-4.0.0.alpha4 tasks/updater/scss.rb