Security update to Drupal 8.4.6
[yaffs-website] / vendor / twbs / bootstrap-sass / Rakefile
1 lib_path = File.join(File.dirname(__FILE__), 'lib')
2 $:.unshift(lib_path) unless $:.include?(lib_path)
3
4 load './tasks/bower.rake'
5
6 require 'rake/testtask'
7 Rake::TestTask.new do |t|
8   t.libs << 'test'
9   t.test_files = FileList['test/**/*_test.rb']
10   t.verbose = true
11 end
12
13 desc 'Test all Gemfiles from test/*.gemfile'
14 task :test_all_gemfiles do
15   require 'term/ansicolor'
16   require 'pty'
17   require 'shellwords'
18   cmd      = 'bundle install --quiet && bundle exec rake --trace'
19   statuses = Dir.glob('./test/gemfiles/*{[!.lock]}').map do |gemfile|
20     env = {'BUNDLE_GEMFILE' => gemfile}
21     cmd_with_env = "  (#{env.map { |k, v| "export #{k}=#{Shellwords.escape v}" } * ' '}; #{cmd})"
22     $stderr.puts Term::ANSIColor.cyan("Testing\n#{cmd_with_env}")
23     PTY.spawn(env, cmd) do |r, _w, pid|
24       begin
25         r.each_line { |l| puts l }
26       rescue Errno::EIO
27         # Errno:EIO error means that the process has finished giving output.
28       ensure
29         ::Process.wait pid
30       end
31     end
32     [$? && $?.exitstatus == 0, cmd_with_env]
33   end
34   failed_cmds = statuses.reject(&:first).map { |(_status, cmd_with_env)| cmd_with_env }
35   if failed_cmds.empty?
36     $stderr.puts Term::ANSIColor.green('Tests pass with all gemfiles')
37   else
38     $stderr.puts Term::ANSIColor.red("Failing (#{failed_cmds.size} / #{statuses.size})\n#{failed_cmds * "\n"}")
39     exit 1
40   end
41 end
42
43 desc 'Dumps output to a CSS file for testing'
44 task :debug do
45   require 'sass'
46   path = Bootstrap.stylesheets_path
47   %w(bootstrap).each do |file|
48     engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
49     File.open("./#{file}.css", 'w') { |f| f.write(engine.render) }
50   end
51 end
52
53 desc 'Convert bootstrap to bootstrap-sass'
54 task :convert, :branch do |t, args|
55   require './tasks/converter'
56   Converter.new(branch: args[:branch]).process_bootstrap
57 end
58
59 desc 'LESS to stdin -> Sass to stdout'
60 task :less_to_scss, :branch do |t, args|
61   require './tasks/converter'
62   puts Converter.new(branch: args[:branch]).convert_less(STDIN.read)
63 end
64
65 desc 'Compile bootstrap-sass to tmp/ (or first arg)'
66 task :compile, :css_path do |t, args|
67   require 'sass'
68   require 'term/ansicolor'
69
70   path = 'assets/stylesheets'
71   css_path = args.with_defaults(css_path: 'tmp')[:css_path]
72   puts Term::ANSIColor.bold "Compiling SCSS in #{path}"
73   Dir.mkdir(css_path) unless File.directory?(css_path)
74   %w(_bootstrap bootstrap/_theme).each do |file|
75     save_path = "#{css_path}/#{file.sub(/(^|\/)?_+/, '\1').sub('/', '-')}.css"
76     puts Term::ANSIColor.cyan("  #{save_path}") + '...'
77     engine    = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
78     css       = engine.render
79     File.open(save_path, 'w') { |f| f.write css }
80   end
81 end
82
83 desc 'Start a dummy (test) Rails app server'
84 task :dummy_rails do
85   require 'rack'
86   require 'term/ansicolor'
87   port = ENV['PORT'] || 9292
88   puts %Q(Starting on #{Term::ANSIColor.cyan "http://localhost:#{port}"})
89   Rack::Server.start(
90     config: 'test/dummy_rails/config.ru',
91     Port: port)
92 end
93
94 task default: :test