Expose installed Supabase CLI version via output (#170)

Expose Supabase CLI version via output
This commit is contained in:
Mark Vainomaa
2023-05-17 13:52:44 +03:00
committed by GitHub
parent 8063edec5e
commit 8b3b75ec99
3 changed files with 23 additions and 1 deletions

View File

@@ -1,5 +1,9 @@
import {exec} from 'child_process'
import os from 'os'
import lt from 'semver/functions/lt'
import {promisify} from 'util'
const doExec = promisify(exec)
// arch in [arm, arm64, x64...] (https://nodejs.org/docs/latest-v16.x/api/os.html#osarch)
// return value in [amd64, arm64, arm]
@@ -31,3 +35,14 @@ export const getDownloadUrl = async (version: string): Promise<string> => {
}
return `https://github.com/supabase/cli/releases/download/v${version}/${filename}`
}
export const determineInstalledVersion = async (): Promise<string> => {
const {stdout} = await doExec('supabase --version')
const version = stdout.trim()
if (!version) {
throw new Error('Could not determine installed Supabase CLI version')
}
return version
}