From 02582083d54f20e63796a518888aad68ace20b52 Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Thu, 30 Mar 2023 16:11:30 -0700 Subject: [PATCH] cmd/tsconnect: allow root directory to be passed in #7339 changed the root directory logic to find the ancestor of the cwd with a go.mod file. This works when running the the binary from this repo directly, but breaks when we're a dependency in another repo. Allow the directory to be passed in via a -rootdir flag (the repo that depends on it can then use `go list -m -f '{{.Dir}}' tailscale.com` or similar to pass in the value). Updates tailscale/corp#10165 Signed-off-by: Mihai Parparita --- cmd/tsconnect/common.go | 3 +++ cmd/tsconnect/tsconnect.go | 1 + 2 files changed, 4 insertions(+) diff --git a/cmd/tsconnect/common.go b/cmd/tsconnect/common.go index 8bf843879..437393b1d 100644 --- a/cmd/tsconnect/common.go +++ b/cmd/tsconnect/common.go @@ -71,6 +71,9 @@ func commonSetup(dev bool) (*esbuild.BuildOptions, error) { } func findRepoRoot() (string, error) { + if *rootDir != "" { + return *rootDir, nil + } cwd, err := os.Getwd() if err != nil { return "", err diff --git a/cmd/tsconnect/tsconnect.go b/cmd/tsconnect/tsconnect.go index 8a806448b..1ab13b355 100644 --- a/cmd/tsconnect/tsconnect.go +++ b/cmd/tsconnect/tsconnect.go @@ -23,6 +23,7 @@ var ( yarnPath = flag.String("yarnpath", "../../tool/yarn", "path yarn executable used to install JavaScript dependencies") fastCompression = flag.Bool("fast-compression", false, "Use faster compression when building, to speed up build time. Meant to iterative/debugging use only.") devControl = flag.String("dev-control", "", "URL of a development control server to be used with dev. If provided without specifying dev, an error will be returned.") + rootDir = flag.String("rootdir", "", "Root directory of repo. If not specified, will be inferred from the cwd.") ) func main() {