@@ -31,10 +31,14 @@ function main {
31
31
done
32
32
33
33
path=" "
34
+ mkdir -p " $HOME /.ntt-cli"
34
35
35
36
# check if there's a package.json in the parent directory, with "name": "@wormhole-foundation/ntt-cli"
36
37
if [ -f " $( dirname $0 ) /package.json" ] && grep -q ' "name": "@wormhole-foundation/ntt-cli"' " $( dirname $0 ) /package.json" ; then
37
38
path=" $( dirname $0 ) /.."
39
+ version=$( git rev-parse HEAD)
40
+ dirty=$( git diff --quiet || echo " -dirty" )
41
+ echo " $version$dirty " > " $HOME /.ntt-cli/version"
38
42
else
39
43
# if branch is set, use it. otherwise use the latest tag of the form "vX.Y.Z+cli" or the 'cli' branch
40
44
if [ -z " $branch " ]; then
@@ -44,7 +48,6 @@ function main {
44
48
# clone to $HOME/.ntt-cli if it doesn't exist, otherwise update it
45
49
echo " Cloning $REPO $branch "
46
50
47
- mkdir -p " $HOME /.ntt-cli"
48
51
path=" $HOME /.ntt-cli/.checkout"
49
52
50
53
if [ ! -d " $path " ]; then
@@ -56,11 +59,24 @@ function main {
56
59
git fetch origin
57
60
# reset hard
58
61
git reset --hard " origin/$branch "
62
+ version=$( git rev-parse HEAD)
63
+ dirty=$( git diff --quiet || echo " -dirty" )
64
+ echo " $version$dirty " > " $HOME /.ntt-cli/version"
59
65
popd
60
66
fi
61
-
62
67
fi
63
68
69
+ absolute_path=" $( cd $path && pwd) "
70
+ echo $absolute_path >> " $HOME /.ntt-cli/version"
71
+
72
+ # jq would be nicer but it's not portable
73
+ # here we make the assumption that the file uses 2 spaces for indentation.
74
+ # this is a bit fragile, but we don't want to catch further nested objects
75
+ # (there might be a "version" in the scripts section, for example)
76
+ version=$( cat " $path /cli/package.json" | grep ' ^ "version":' | cut -d ' "' -f 4)
77
+ echo " Installing ntt CLI version $version "
78
+ echo " $version " >> " $HOME /.ntt-cli/version"
79
+
64
80
install_cli " $path "
65
81
}
66
82
0 commit comments