2024-06-19 23:36:03 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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-22 07:17:13 +02:00
|
|
|
Dir.chdir(dirs.root) do
|
2024-02-18 13:24:54 +01:00
|
|
|
sh "rm -rf node_modules/.cache/"
|
2024-08-30 15:16:42 +02:00
|
|
|
sh "rm -rf #{nanoc.output_dir}/*"
|
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-22 07:17:13 +02:00
|
|
|
Listen.to(dirs.content) {
|
2024-06-19 23:31:23 +02:00
|
|
|
Nanoc::CLI.run(["compile"])
|
2024-06-22 07:17:13 +02:00
|
|
|
}.start
|
2024-06-19 23:31:23 +02:00
|
|
|
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|
|
2024-06-22 07:17:13 +02:00
|
|
|
ENV["SASS_PATH"] = File.join(dirs.content, "css")
|
2024-06-19 23:31:23 +02:00
|
|
|
ENV["buildenv"] = args.buildenv || ENV["buildenv"] || "development"
|
|
|
|
end
|
2023-07-25 20:32:57 +02:00
|
|
|
end
|