-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If no lake location is specified, zed will use a per-os default location. Also if the default location is used, zed will first check if there's a service on 9867 and opt to connect to that instead of operating locally.
- Loading branch information
Showing
5 changed files
with
80 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package lakeflags | ||
|
||
import ( | ||
"os" | ||
"os/user" | ||
"path/filepath" | ||
"runtime" | ||
) | ||
|
||
var defaultDataDir string | ||
|
||
func init() { | ||
defaultDataDir = getDefaultDataDir() | ||
} | ||
|
||
// getDefaultDataDir returns the default data directory for the current user. | ||
// Derived from https://github.com/btcsuite/btcd/blob/master/btcutil/appdata.go | ||
func getDefaultDataDir() string { | ||
// Resolve the XDG data home directory if set. | ||
if xdgDataHome := os.Getenv("XDG_DATA_HOME"); xdgDataHome != "" { | ||
return filepath.Join(xdgDataHome, "zed") | ||
} | ||
// Get the OS specific home directory via the Go standard lib. | ||
var homeDir string | ||
usr, err := user.Current() | ||
if err == nil { | ||
homeDir = usr.HomeDir | ||
} | ||
// Fall back to standard HOME environment variable that works | ||
// for most POSIX OSes if the directory from the Go standard | ||
// lib failed. | ||
if err != nil || homeDir == "" { | ||
homeDir = os.Getenv("HOME") | ||
} | ||
switch runtime.GOOS { | ||
case "windows": | ||
// Windows XP and before didn't have a LOCALAPPDATA, so fallback | ||
// to regular APPDATA when LOCALAPPDATA is not set. | ||
appData := os.Getenv("LOCALAPPDATA") | ||
if appData == "" { | ||
appData = os.Getenv("APPDATA") | ||
} | ||
if appData != "" { | ||
return filepath.Join(appData, "zed") | ||
} | ||
case "darwin": | ||
if homeDir != "" { | ||
return filepath.Join(homeDir, "Library", | ||
"Application Support", "zed") | ||
} | ||
default: | ||
if homeDir != "" { | ||
return filepath.Join(homeDir, ".zed") | ||
} | ||
} | ||
// Return an empty string which will cause an error if a default data | ||
// directory cannot be found. | ||
return "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
script: | | ||
! zed ls -lake '' | ||
! zed serve | ||
! zed serve -lake '' | ||
outputs: | ||
- name: stderr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
script: | | ||
! zc -C -s 'from p' | ||
! zc -lake='' -C -s 'from p' | ||
echo === >&2 | ||
export ZED_LAKE=test | ||
zed init | ||
|