Skip to content

Instantly share code, notes, and snippets.

@etiennejcharles
Forked from noniq/concat.rb
Created May 22, 2014 06:37
Show Gist options
  • Save etiennejcharles/c2ca098f54d268ed036e to your computer and use it in GitHub Desktop.
Save etiennejcharles/c2ca098f54d268ed036e to your computer and use it in GitHub Desktop.
# Usage:
# ruby concat.rb /path-to-compass-gem/frameworks/compass/stylesheets/_compass.scss > compass-all.scss
@seen = []
def concat(file)
File.foreach(file) do |line|
if line =~ /^\s?@import "(.+?)";/
import = $1
unless @seen.include?(import)
@seen << import
puts "// IMPORTING #{import}"
import_filename = import.gsub(%r{([^/]+)$}, '_\1.scss')
import_path = File.exist?(File.dirname(file) + "/" + import_filename) ? File.dirname(file) : @basedir
concat("#{import_path}/" + import_filename)
end
else
puts line
end
end
end
@basedir = File.dirname(File.expand_path(ARGV[0]))
concat ARGV[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment