Skip to content

Commit 288c820

Browse files
authored
Merge pull request #80 from semaphoreci/cache-on-mac
Linux/Mac current timestamp in milis support
2 parents 965acc0 + 73b6867 commit 288c820

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

cache

+19-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ cache::normalize_string() {
3838
echo "$result"
3939
}
4040

41+
cache::current_timestamp_in_milis() {
42+
DIST=$(uname)
43+
44+
case $DIST in
45+
Darwin)
46+
gdate +%s%3N
47+
;;
48+
Linux)
49+
date +%s%3N
50+
;;
51+
*)
52+
echo "Unsupported distro $DIST"
53+
exit 1
54+
;;
55+
esac
56+
}
57+
4158
cache::duration() {
4259

4360
local lftp_cmd
@@ -46,9 +63,9 @@ cache::duration() {
4663
local duration
4764

4865
lftp_cmd=$1; shift
49-
start=$(date +%s%3N)
66+
start=$(cache::current_timestamp_in_milis)
5067
$lftp_cmd "$@"
51-
end=$(date +%s%3N)
68+
end=$(cache::current_timestamp_in_milis)
5269
duration=$(( $end - $start ))
5370

5471
echo $duration > /tmp/duration

0 commit comments

Comments
 (0)