Skip to content

Commit

Permalink
.functions: Add file size output to targz
Browse files Browse the repository at this point in the history
  • Loading branch information
heitorPB authored and mathiasbynens committed Jun 3, 2016
1 parent ef819d5 commit 5b3c841
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function targz() {

size=$(
stat -f"%z" "${tmpFile}" 2> /dev/null; # OS X `stat`
stat -c"%s" "${tmpFile}" 2> /dev/null # GNU `stat`
stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat`
);

local cmd="";
Expand All @@ -50,10 +50,16 @@ function targz() {
fi;
fi;

echo "Compressing .tar using \`${cmd}\`";
echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`";
"${cmd}" -v "${tmpFile}" || return 1;
[ -f "${tmpFile}" ] && rm "${tmpFile}";
echo "${tmpFile}.gz created successfully.";

zippedSize=$(
stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # OS X `stat`
stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat`
);

echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
}

# Determine size of a file or total size of a directory
Expand Down

0 comments on commit 5b3c841

Please sign in to comment.