diff --git a/timestamp.sh b/timestamp.sh index 408b864c..dc7121eb 100755 --- a/timestamp.sh +++ b/timestamp.sh @@ -1,7 +1,13 @@ -# Timestamp a git/npm project in node JS +#!/bin/bash + echo "export default {" date -u '+buildTime: "%Y-%m-%dT%H:%M:%SZ",' git log | grep commit | head -1 | sed -e 's/ /: "/' | sed -e 's/$/",/' -echo npmInfo: -npm version -echo "};" +echo " npmInfo: {" + npm version | sed 's/\x1b\[[0-9;:]*[mG]//g' | grep -v '^{' | while read line; do + key=$(echo "$line" | cut -d ':' -f 1 | tr -d ' ') + value=$(echo "$line" | cut -d ':' -f 2- | tr -d ' ') + echo " \"${key}\": \"${value}\"," + done +echo " }" +echo "};" \ No newline at end of file