al-quran.reflectslight.io/Rakefile.rb

67 lines
1.2 KiB
Ruby
Raw Normal View History

2022-11-02 04:49:43 +01:00
# frozen_string_literal: true
2023-06-30 21:06:20 +02:00
require "bundler/setup"
2022-11-08 11:45:40 +01:00
require "ryo"
2023-06-30 21:14:21 +02:00
require "yaml"
2023-07-13 02:31:54 +02:00
load "tasks/deploy.rake"
2023-06-30 21:14:21 +02:00
build_dir = Ryo.from(YAML.load_file("./nanoc.yaml")).output_dir
2022-10-31 19:34:23 +01:00
namespace :nanoc do
task :compile do
2023-03-25 12:56:46 +01:00
ENV["SASS_PATH"] = "./src/css/"
2023-03-25 12:02:55 +01:00
sh "bundle exec nanoc co"
2022-10-31 19:34:23 +01:00
end
2022-11-08 11:45:40 +01:00
task :clean do
sh "rm -rf #{build_dir}"
end
2023-07-09 03:30:39 +02:00
task watch: [:compile] do
require "listen"
Listen.to File.join(Dir.getwd, "src"), force_polling: true do
sh "rake build"
end.start
sleep
end
2022-10-31 19:34:23 +01:00
end
2023-06-30 21:06:20 +02:00
desc "Build the website"
2022-11-02 11:33:58 +01:00
task build: "nanoc:compile"
2022-10-31 19:34:23 +01:00
2023-07-09 03:30:39 +02:00
desc "Trigger a build when src/ is modified"
task "build:watch" => "nanoc:watch"
2023-06-30 21:06:20 +02:00
desc "Clean the build directory"
task clean: "nanoc:clean"
2023-06-30 21:14:21 +02:00
desc "Serve the website on localhost"
task :server do
require "server"
s = Server.for_dir(build_dir)
s.start(block: true)
rescue Interrupt
s.stop
2022-11-03 23:09:51 +01:00
end
2023-01-05 04:14:54 +01:00
namespace :lint do
desc "Run rubocop (Ruby)"
task :rubocop do
2023-03-12 20:50:19 +01:00
sh "bundle exec rubocop"
2022-11-02 04:38:46 +01:00
end
2023-01-05 04:14:54 +01:00
desc "Run eslint (TypeScript)"
task :eslint do
2022-11-02 04:38:46 +01:00
sh "npm run eslint"
end
2023-01-05 04:14:54 +01:00
namespace :eslint do
desc "Run eslint with the --fix option (TypeScript)"
task :fix do
sh "npm run eslint-autofix"
end
end
2022-11-02 04:38:46 +01:00
end
task lint: ["lint:rubocop", "lint:eslint"]
2023-07-05 04:17:18 +02:00
task default: "build"