Skip to content

Commit c463a0e

Browse files
committed
cli: include remote in version string if it's not the foundation repo
this just makes it easier to know where the cli was installed from
1 parent d4a06f0 commit c463a0e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

cli/install.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ function main {
7474
# this is a bit fragile, but we don't want to catch further nested objects
7575
# (there might be a "version" in the scripts section, for example)
7676
version=$(cat "$path/cli/package.json" | grep '^ "version":' | cut -d '"' -f 4)
77-
echo "Installing ntt CLI version $version"
7877
echo "$version" >> "$HOME/.ntt-cli/version"
7978

79+
remote_url=$(git -C "$path" remote get-url origin)
80+
echo "$remote_url" >> "$HOME/.ntt-cli/version"
81+
82+
echo "Installing ntt CLI version $version"
8083
install_cli "$path"
8184
}
8285

cli/src/index.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,13 @@ yargs(hideBin(process.argv))
204204
if (!ver) {
205205
return "unknown";
206206
}
207-
const { version, commit, path } = ver;
207+
const { version, commit, path, remote } = ver;
208208
const defaultPath = `${process.env.HOME}/.ntt-cli/.checkout`;
209+
const remoteString = remote.includes("wormhole-foundation") ? "" : `${remote}@`;
209210
if (path === defaultPath) {
210-
return `ntt v${version} (${commit})`;
211+
return `ntt v${version} (${remoteString}${commit})`;
211212
} else {
212-
return `ntt v${version} (${commit}) from ${path}`;
213+
return `ntt v${version} (${remoteString}${commit}) from ${path}`;
213214
}
214215
})())
215216
// config group of commands
@@ -1853,12 +1854,12 @@ function retryWithExponentialBackoff<T>(
18531854
return attempt(0);
18541855
}
18551856

1856-
function nttVersion(): { version: string, commit: string, path: string } | null {
1857+
function nttVersion(): { version: string, commit: string, path: string, remote: string } | null {
18571858
const nttDir = `${process.env.HOME}/.ntt-cli`;
18581859
try {
18591860
const versionFile = fs.readFileSync(`${nttDir}/version`).toString().trim();
1860-
const [commit, installPath, version] = versionFile.split("\n");
1861-
return { version, commit, path: installPath };
1861+
const [commit, installPath, version, remote] = versionFile.split("\n");
1862+
return { version, commit, path: installPath, remote };
18621863
} catch {
18631864
return null;
18641865
}

0 commit comments

Comments
 (0)