Sha256: 63ec743fb7acee75f912e6d39756342a9ad6ab8a08a691d00c2cbfd971420cf5

Contents?: true

Size: 763 Bytes

Versions: 6

Compression:

Stored size: 763 Bytes

Contents

module SCSSBeautifier
  class CLI
    DEFAULT = File.realpath(File.join(File.dirname(__FILE__), "..", "..", "data", "default_config.yml")).freeze
    # Takes an array of arguments
    # Returns exit code
    def run(args)
      options = Options.new.parse(args)

      contents = File.read(args.first)
      engine = Sass::Engine.new(contents, cache: false, syntax: :scss)

      tree = engine.to_tree
      config = Config.new(options[:config] || DEFAULT)

      config.formatters.each do |formatter|
        formatter.send(:visit, tree)
      end

      output = SCSSBeautifier::Convert.visit(tree, {indent: config.tab_style}, :scss)
      if options[:in_place]
        File.write(args.first, output)
      else
        puts output
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
scss_beautifier-0.1.17 lib/scss_beautifier/cli.rb
scss_beautifier-0.1.16 lib/scss_beautifier/cli.rb
scss_beautifier-0.1.15 lib/scss_beautifier/cli.rb
scss_beautifier-0.1.14 lib/scss_beautifier/cli.rb
scss_beautifier-0.1.13 lib/scss_beautifier/cli.rb
scss_beautifier-0.1.12 lib/scss_beautifier/cli.rb