Skip to content

Commit

Permalink
Fix Windows build (zk-org#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
codito authored Feb 22, 2022
1 parent e037bef commit 83c15cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
# Dependency directories (remove the comment below to include it)
# vendor/

# IDEs/Editors
.vscode/

notebook.db
zk
3 changes: 2 additions & 1 deletion internal/core/notebook_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func (ns *NotebookStore) locateNotebook(path string) (string, error) {

var locate func(string) (string, error)
locate = func(currentPath string) (string, error) {
if currentPath == "/" || currentPath == "." {
// For Windows, the root dir may end with volume name, e.g. E:\\
if currentPath == "/" || currentPath == filepath.VolumeName(currentPath)+"\\" || currentPath == "." {
return "", ErrNotebookNotFound(path)
}
exists, err := ns.fs.DirExists(filepath.Join(currentPath, ".zk"))
Expand Down
5 changes: 3 additions & 2 deletions internal/util/exec/exec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package exec
import (
"fmt"
"os/exec"
"strings"
"syscall"
)

// CommandFromString returns a Cmd running the given command.
func CommandFromString(command string) *exec.Cmd {
func CommandFromString(command string, args ...string) *exec.Cmd {
cmd := exec.Command("cmd")
cmd.SysProcAttr = &syscall.SysProcAttr{
HideWindow: false,
CmdLine: fmt.Sprintf(` /v:on/s/c "%s"`, command),
CmdLine: fmt.Sprintf(` /v:on/s/c "%s %s"`, command, strings.Join(args[:], " ")),
CreationFlags: 0,
}
return cmd
Expand Down

0 comments on commit 83c15cc

Please sign in to comment.