From 33247773f462535e9607612ffec63171b33eaadf Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 6 Mar 2021 20:34:50 +0900 Subject: [PATCH] Modify & create `rake` tasks. --- tasks/init.rake | 15 +++++++++++++++ tasks/production.rake | 2 +- tasks/staging.rake | 2 +- tasks/tcardgen.rake | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tasks/init.rake diff --git a/tasks/init.rake b/tasks/init.rake new file mode 100644 index 0000000..63ec839 --- /dev/null +++ b/tasks/init.rake @@ -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 diff --git a/tasks/production.rake b/tasks/production.rake index 45572c1..f898dbb 100644 --- a/tasks/production.rake +++ b/tasks/production.rake @@ -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' diff --git a/tasks/staging.rake b/tasks/staging.rake index ea59619..4ee81a2 100644 --- a/tasks/staging.rake +++ b/tasks/staging.rake @@ -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' diff --git a/tasks/tcardgen.rake b/tasks/tcardgen.rake index 93f3ae6..422761d 100644 --- a/tasks/tcardgen.rake +++ b/tasks/tcardgen.rake @@ -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