rails/actiontext/Rakefile

55 lines
1.5 KiB
Ruby
Raw Normal View History

2019-01-05 08:43:11 +08:00
# frozen_string_literal: true
require "bundler/setup"
require "bundler/gem_tasks"
require "rake/testtask"
task :package
ENV["RAILS_MINITEST_PLUGIN"] = "true"
2019-01-05 08:43:11 +08:00
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"].exclude("test/system/**/*", "test/dummy/**/*")
t.verbose = true
end
Rake::TestTask.new "test:system" do |t|
t.libs << "test"
t.test_files = FileList["test/system/**/*_test.rb"]
2019-01-05 08:43:11 +08:00
t.verbose = true
end
namespace :test do
task :isolated do
FileList["test/**/*_test.rb"].exclude("test/system/**/*", "test/dummy/**/*").all? do |file|
sh(Gem.ruby, "-w", "-Ilib", "-Itest", file)
end || raise("Failures")
end
end
task :vendor_trix do
require "importmap-rails"
require "importmap/packager"
packager = Importmap::Packager.new(vendor_path: "app/assets/javascripts")
imports = packager.import("trix", from: "unpkg")
imports.each do |package, url|
url.gsub!("esm.min.js", "umd.js")
puts %(Vendoring "#{package}" to #{packager.vendor_path}/#{package}.js via download from #{url})
packager.download(package, url)
css_url = url.gsub("umd.js", "css")
puts %(Vendoring "#{package}" to #{packager.vendor_path}/#{package}.css via download from #{css_url})
response = Net::HTTP.get_response(URI(css_url))
if response.code == "200"
File.open(Pathname.new("app/assets/stylesheets/trix.css"), "w+") do |file|
file.write response.body
end
end
end
end
2019-01-05 08:43:11 +08:00
task default: :test