Skip to content

Commit 66bbb37

Browse files
committed
imporved timestamp bash
1 parent b39d1ff commit 66bbb37

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

timestamp.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
# Timestamp a git/npm project in node JS
2-
echo "export const versionInfo = {"
1+
#!/bin/bash
2+
3+
echo "export default {"
34
date -u '+buildTime: "%Y-%m-%dT%H:%M:%SZ",'
45
git log | grep commit | head -1 | sed -e 's/ /: "/' | sed -e 's/$/",/'
5-
echo npmInfo:
6-
npm version
7-
echo "};"
6+
echo " npmInfo: {"
7+
npm version | sed 's/\x1b\[[0-9;:]*[mG]//g' | grep -v '^{' | while read line; do
8+
key=$(echo "$line" | cut -d ':' -f 1 | tr -d ' ')
9+
value=$(echo "$line" | cut -d ':' -f 2- | tr -d ' ')
10+
echo " \"${key}\": \"${value}\","
11+
done
12+
echo " }"
13+
echo "};"

0 commit comments

Comments
 (0)