Improved the tool scripts.
- Avoid the empty lastmod file. - Check if there is no post. - Fixed the prompt message.
This commit is contained in:
parent
c0ba181246
commit
0d47beba97
3 changed files with 15 additions and 2 deletions
|
@ -45,6 +45,7 @@ read_tags() {
|
|||
|
||||
|
||||
init() {
|
||||
|
||||
if [[ -d categories ]]; then
|
||||
rm -rf categories
|
||||
fi
|
||||
|
@ -53,6 +54,10 @@ init() {
|
|||
rm -rf tags
|
||||
fi
|
||||
|
||||
if [[ ! -d _posts ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir categories tags
|
||||
}
|
||||
|
||||
|
@ -130,6 +135,7 @@ create_pages() {
|
|||
|
||||
|
||||
main() {
|
||||
|
||||
init
|
||||
|
||||
for _file in $(ls "_posts")
|
||||
|
|
|
@ -19,6 +19,7 @@ OUTPUT_FILE=updates.yml
|
|||
|
||||
|
||||
_init() {
|
||||
|
||||
if [[ ! -d "$OUTPUT_DIR" ]]; then
|
||||
mkdir "$OUTPUT_DIR"
|
||||
fi
|
||||
|
@ -27,7 +28,9 @@ _init() {
|
|||
rm -f "$OUTPUT_DIR/$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
touch "$OUTPUT_DIR/$OUTPUT_FILE"
|
||||
if [[ ! -d $POST_DIR ]]; then
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,6 +58,10 @@ _has_changed() {
|
|||
_dump() {
|
||||
local _lasmod="`git log -1 --pretty=%ad --date=iso $2`"
|
||||
|
||||
if [[ ! -f "$OUTPUT_DIR/$OUTPUT_FILE" ]]; then
|
||||
touch "$OUTPUT_DIR/$OUTPUT_FILE"
|
||||
fi
|
||||
|
||||
echo "-" >> "$OUTPUT_DIR/$OUTPUT_FILE"
|
||||
echo " filename: '$1'" >> "$OUTPUT_DIR/$OUTPUT_FILE"
|
||||
echo " lastmod: '$_lasmod'" >> "$OUTPUT_DIR/$OUTPUT_FILE"
|
||||
|
|
|
@ -19,7 +19,7 @@ check_status() {
|
|||
local _change=$(git status . -s)
|
||||
|
||||
if [[ ! -z ${_change} ]]; then
|
||||
echo "Warning: Commit the changes of the changes first:"
|
||||
echo "Warning: Commit the following changes first:"
|
||||
echo "$_change"
|
||||
exit 1
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue