al-quran.reflectslight.io/rake/tasks/nanoc.rake

36 lines
870 B
Ruby
Raw Normal View History

2024-06-19 23:36:03 +02:00
# frozen_string_literal: true
cwd = File.realpath File.join(__dir__, "..", "..")
2023-07-25 20:32:57 +02:00
namespace :nanoc do
2024-06-19 23:47:17 +02:00
desc "Clean directories"
2023-07-25 20:32:57 +02:00
task :clean do
Dir.chdir(cwd) do
sh "rm -rf node_modules/.cache/"
sh "rm -rf build/"
2024-02-24 02:38:50 +01:00
sh "rm -rf tmp/"
end
2023-07-25 20:32:57 +02:00
end
2024-06-19 23:47:17 +02:00
desc "Produce the build directory"
task :build, %i[buildenv] => %i[setenv] do |t, args|
Nanoc::CLI.run(["compile"])
end
2024-06-19 23:47:17 +02:00
desc "Produce the build directory on-demand"
task :watch, %i[buildenv] => %i[setenv nanoc:build] do |t, args|
require "listen"
2024-06-20 18:17:19 +02:00
Listen.to(File.join(cwd, "src")) do
Nanoc::CLI.run(["compile"])
end.start
sleep
rescue Interrupt
warn "SIGINT: exit"
2023-11-27 22:18:10 +01:00
exit
2023-07-25 20:32:57 +02:00
end
task :setenv, %i[buildenv] do |t, args|
ENV["SASS_PATH"] = File.join(cwd, "src", "css")
ENV["buildenv"] = args.buildenv || ENV["buildenv"] || "development"
end
2023-07-25 20:32:57 +02:00
end