From 9ada4948cb4f1ca4d08e36a5f293a79cdbc781fe Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Thu, 28 Mar 2024 19:03:32 +0300 Subject: [PATCH] update build script --- README.md | 11 +++++++++-- make_dist.sh | 56 ++++++++++++++++++++++++++-------------------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index d33dfec..e944207 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ -YTCget ------- +YTCget — Show YouTube video cover +================================= ![Preview](preview.png) **Thanks:** + @takien: for [youtubeID.js](https://gist.github.com/takien/4077195) script. + +Build +----- + +**Requirements:** + +* [minify-html](https://github.com/wilsonzlin/minify-html/) diff --git a/make_dist.sh b/make_dist.sh index 3efb2f3..9388ed8 100755 --- a/make_dist.sh +++ b/make_dist.sh @@ -1,34 +1,34 @@ -#!/bin/sh +#!/bin/bash echo -e "Making \033[0;31mYTCget\033[0m dist..." -if [ -d "./dist" ]; then - echo -en "Cleaning \033[0;31m./dist/\033[0m directory..." - rm -rf "./dist/*" - echo " Complete!" - - echo -n "Copying static files..." - cp ./src/youtubeID.js ./dist/youtubeID.js - cp ./src/ytcg.js ./dist/ytcg.js - echo " Complete!" - - echo -n "Minifying files..." - minify-html ./src/styles.css -o ./dist/styles.css - minify-html \ - --do-not-minify-doctype \ - --keep-closing-tags \ - --keep-spaces-between-attributes \ - --keep-html-and-head-opening-tags \ - ./src/index.html -o ./dist/index.html - - GIT_COMMIT_HASH=$(git rev-parse --short HEAD) - sed -i -- "s/{GIT_COMMIT_HASH}/$GIT_COMMIT_HASH/g" ./dist/index.html - echo " Complete!" - - echo -en "Making \033[0;31mytcg-$GIT_COMMIT_HASH.tar.xz\033[0m file..." - tar -cJf "ytcg-$GIT_COMMIT_HASH.tar.xz" ./dist/* - echo " Complete!" -else +if [ ! -d "./dist" ]; then echo -e "Make \033[0;31m./dist/\033[0m directory." mkdir "./dist/" fi + +echo -en "Cleaning \033[0;31m./dist/\033[0m directory..." +rm -rf "./dist/*" +echo " Complete!" + +echo -n "Copying static files..." +cp ./src/youtubeID.js ./dist/youtubeID.js +cp ./src/ytcg.js ./dist/ytcg.js +echo " Complete!" + +echo -n "Minifying files..." +minify-html ./src/styles.css -o ./dist/styles.css +minify-html \ + --do-not-minify-doctype \ + --keep-closing-tags \ + --keep-spaces-between-attributes \ + --keep-html-and-head-opening-tags \ + ./src/index.html -o ./dist/index.html + +GIT_COMMIT_HASH=$(git rev-parse --short HEAD) +sed -i -- "s/{GIT_COMMIT_HASH}/$GIT_COMMIT_HASH/g" ./dist/index.html +echo " Complete!" + +echo -en "Making \033[0;31mytcg-$GIT_COMMIT_HASH.tar.xz\033[0m file..." +tar -cJf "ytcg-$GIT_COMMIT_HASH.tar.xz" ./dist/* +echo " Complete!"