1
0
Fork 0
mirror of https://github.com/twbs/bootstrap-sass.git synced 2022-11-09 12:27:02 -05:00

Create directory from argument in compile task

Previously, the compile task would always create a tmp/ directory, even
if another directory is specified. The specified directory was also not
created if necessary.
This commit is contained in:
Carlos Diaz-Padron 2014-03-19 21:53:27 -04:00
parent 5db7be8e09
commit c624370acb

View file

@ -37,13 +37,14 @@ task :compile, :css_path do |t, args|
require 'term/ansicolor'
path = 'vendor/assets/stylesheets'
css_path = args.with_defaults(css_path: 'tmp')[:css_path]
puts Term::ANSIColor.bold "Compiling SCSS in #{path}"
Dir.mkdir(css_path) unless File.directory?(css_path)
%w(bootstrap bootstrap/_theme).each do |file|
save_path = "#{args.with_defaults(css_path: 'tmp')[:css_path]}/#{file.sub(/(^|\/)?_+/, '\1').sub('/', '-')}.css"
save_path = "#{css_path}/#{file.sub(/(^|\/)?_+/, '\1').sub('/', '-')}.css"
puts Term::ANSIColor.cyan(" #{save_path}") + '...'
engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
css = engine.render
Dir.mkdir('tmp') unless File.directory?('tmp')
File.open(save_path, 'w') { |f| f.write css }
end
end