2024-06-19 23:36:03 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-06-19 23:31:23 +02:00
|
|
|
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
|
2024-06-19 23:31:23 +02:00
|
|
|
Dir.chdir(cwd) do
|
2024-02-18 13:24:54 +01:00
|
|
|
sh "rm -rf node_modules/.cache/"
|
2024-06-19 23:31:23 +02:00
|
|
|
sh "rm -rf build/"
|
2024-02-24 02:38:50 +01:00
|
|
|
sh "rm -rf tmp/"
|
2024-02-18 13:24:54 +01:00
|
|
|
end
|
2023-07-25 20:32:57 +02:00
|
|
|
end
|
|
|
|
|
2024-06-19 23:47:17 +02:00
|
|
|
desc "Produce the build directory"
|
2024-06-19 23:31:23 +02:00
|
|
|
task :build, %i[buildenv] => %i[setenv] do |t, args|
|
|
|
|
Nanoc::CLI.run(["compile"])
|
2023-10-28 15:47:43 +02:00
|
|
|
end
|
|
|
|
|
2024-06-19 23:47:17 +02:00
|
|
|
desc "Produce the build directory on-demand"
|
2024-06-19 23:31:23 +02:00
|
|
|
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
|
2024-06-19 23:31:23 +02:00
|
|
|
Nanoc::CLI.run(["compile"])
|
|
|
|
end.start
|
|
|
|
sleep
|
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
|
2024-06-19 23:31:23 +02:00
|
|
|
|
|
|
|
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
|