Is there a way to get the Pulumi version in Typesc...
# general
Is there a way to get the Pulumi version in Typescript?
Interested in this to ensure that my pulumi program is only ran with a particular version.
I don't think that property is exported though.
It's in the docs though 🤔
Wouldn’t setting a specific version in
solve this for you?
You can get this with automation api. It’s a property on LocalWorkspace
For me but not if other devs are also running pulumi up.
I'd like to, for example, ensure that any dev running pulumi up has exactly v3.2.1.
This is similar to Terraform version constraints:
I can do this myself but it'd be cool to have it built in.
Copy code
export function ensureVersionMatches(desiredVersion: string) {
    const result = proc.spawnSync("pulumi", ["version"], {
        stdio: ["pipe", "pipe", "inherit"]
    if (result.status != 0) {
        throw new pulumi.RunError(`Pulumi version check exited with non-zero status ${result.status}.`)
    const versionString = String(result.stdout)
    if (versionString != desiredVersion) {
        throw new pulumi.RunError(`Pulumi current version ${versionString} does not match desired version ${desiredVersion}`)
    return versionString