Modify & create `rake` tasks.

This commit is contained in:
Kazuhiro MUSASHI 2021-03-06 20:34:50 +09:00
parent f3e5cd5587
commit 33247773f4
4 changed files with 19 additions and 2 deletions

15
tasks/init.rake Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env rake
URL = 'https://github.com/yuru7/HackGen/releases/download/v2.3.0/HackGenNerd_v2.3.0.zip'
TMP_FILE = '/tmp/font.zip'
TMP_DIR = '/tmp/font'
TARGET = 'assets/font/'
desc 'Download the necessary assets.'
task :init do
unless File.exist?('assets/font/HackGen35Nerd-Bold.ttf')
sh "wget #{URL} -O #{TMP_FILE}"
sh "rm -rf #{TMP_DIR} && unzip #{TMP_FILE} -d #{TMP_DIR}"
sh "find #{TMP_DIR} -type f -name *.ttf | xargs -I% -n 1 cp -p % #{TARGET}"
end
end

View File

@ -3,7 +3,7 @@
require 'find'
desc 'Deploy the hugo contents to the server'
task :prod => [:prep] do
task :prod => [:init, :prep, :tcard] do
sh 'hugo -v --minify'
sh 'find public -type f -name "*.gz" -delete'

View File

@ -3,7 +3,7 @@
require 'find'
desc 'Deploy the hugo contents to the server'
task :stag => [:prep] do
task :stag => [:init, :prep, :tcard] do
sh 'hugo -e staging -v --minify'
sh 'find public -type f -name "*.gz" -delete'

View File

@ -24,4 +24,6 @@ task :tcard do
sh "img2webp -lossy -q 50 #{src} -o #{dest}"
end
sh "find #{OGP_DIR} -type f -name '*.png' | xargs -t --no-run-if-empty rm"
end