-
-
Save etiennejcharles/c2ca098f54d268ed036e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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