Sha256: 72fb28854fdc6ec5607b38b346ebfa5d66bdc1eeed893831d1f0a0c7f5f77c2e

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 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.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

2 entries across 2 versions & 1 rubygems

Version Path
scss_beautifier-0.1.11 lib/scss_beautifier/cli.rb
scss_beautifier-0.1.10 lib/scss_beautifier/cli.rb