Skip to content

Commit

Permalink
cli: detect local installations of sst in node_modules and use that w…
Browse files Browse the repository at this point in the history
…hen global version is used
  • Loading branch information
thdxr committed Jul 22, 2024
1 parent 9ad1d4e commit bb0a32e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ import (
var version = "dev"

func main() {
// check if node_modules/.bin/sst exists
nodeModulesBinPath := filepath.Join("node_modules", ".bin", "sst")
if _, err := os.Stat(nodeModulesBinPath); err == nil {
// forward command to node_modules/.bin/sst
fmt.Println(ui.TEXT_WARNING_BOLD.Render("Warning: ") + "You are using a global installation of SST but you also have a local installation specified in your package.json. The local installation will be used but you should typically run it through your package manager.")
cmd := exec.Command(nodeModulesBinPath, os.Args[1:]...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Env = os.Environ()
if err := cmd.Run(); err != nil {
os.Exit(1)
}
return
}
telemetry.SetVersion(version)
defer telemetry.Close()
telemetry.Track("cli.start", map[string]interface{}{
Expand Down
Binary file added examples/aws-astro/bun.lockb
Binary file not shown.
16 changes: 16 additions & 0 deletions examples/aws-astro/sst-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* tslint:disable */
/* eslint-disable */
import "sst"
declare module "sst" {
export interface Resource {
MyBucket: {
name: string
type: "sst.aws.Bucket"
}
MyWeb: {
type: "sst.aws.Astro"
url: string
}
}
}
export {}

0 comments on commit bb0a32e

Please sign in to comment.