2023-07-25 20:32:57 +02:00
|
|
|
namespace :nanoc do
|
2024-02-18 13:24:54 +01:00
|
|
|
require "bundler/setup"
|
2024-03-15 16:52:39 +01:00
|
|
|
root = File.realpath File.join(__dir__, "..", "..")
|
2023-07-25 20:32:57 +02:00
|
|
|
|
2024-02-18 13:24:54 +01:00
|
|
|
desc "Clean the build/ directory"
|
2023-07-25 20:32:57 +02:00
|
|
|
task :clean do
|
2024-03-15 16:52:39 +01:00
|
|
|
Dir.chdir(root) do
|
2024-02-18 13:24:54 +01:00
|
|
|
sh "rm -rf node_modules/.cache/"
|
2024-02-24 02:38:50 +01:00
|
|
|
sh "rm -rf tmp/"
|
2024-02-18 13:24:54 +01:00
|
|
|
sh "rm -rf build"
|
|
|
|
end
|
2023-07-25 20:32:57 +02:00
|
|
|
end
|
|
|
|
|
2024-02-18 13:24:54 +01:00
|
|
|
desc "Produce the build/ directory"
|
|
|
|
task :build, [:buildenv] do |t, args|
|
2024-03-15 16:52:39 +01:00
|
|
|
Dir.chdir(root) do
|
2024-02-18 13:24:54 +01:00
|
|
|
buildenv = args.buildenv || ENV["buildenv"] || "development"
|
2024-03-15 16:52:39 +01:00
|
|
|
sass_path = File.join(root, "src", "css")
|
2024-02-24 00:58:28 +01:00
|
|
|
sh "rm -rf build/al-quran/css/"
|
2024-02-18 13:24:54 +01:00
|
|
|
Bundler.with_unbundled_env {
|
2024-02-18 22:01:55 +01:00
|
|
|
sh "SASS_PATH=#{sass_path} buildenv=#{buildenv} bundle exec nanoc co"
|
2024-02-18 13:24:54 +01:00
|
|
|
}
|
|
|
|
end
|
2023-10-28 15:47:43 +02:00
|
|
|
end
|
|
|
|
|
2024-02-18 13:24:54 +01:00
|
|
|
desc "Produce the build/ directory on-demand"
|
|
|
|
task watch: ['nanoc:build'] do
|
2024-03-15 16:52:39 +01:00
|
|
|
Dir.chdir(root) do
|
2024-02-18 13:24:54 +01:00
|
|
|
require "listen"
|
2024-03-15 16:52:39 +01:00
|
|
|
srcdir = File.join(root, "src")
|
|
|
|
Listen.to(srcdir) do
|
2024-02-18 13:24:54 +01:00
|
|
|
Bundler.with_unbundled_env { sh "rake nanoc:build" }
|
|
|
|
end.start
|
|
|
|
sleep
|
|
|
|
end
|
2023-11-27 22:11:22 +01:00
|
|
|
rescue Interrupt
|
|
|
|
warn "SIGINT: exit"
|
2023-11-27 22:18:10 +01:00
|
|
|
exit
|
2023-07-25 20:32:57 +02:00
|
|
|
end
|
|
|
|
end
|