Fix Windows build (#171)

This commit is contained in:
codito 2022-02-22 19:03:30 +05:30 committed by GitHub
parent e037befdf1
commit 83c15cc927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

3
.gitignore vendored
View File

@ -14,5 +14,8 @@
# Dependency directories (remove the comment below to include it)
# vendor/
# IDEs/Editors
.vscode/
notebook.db
zk

View File

@ -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"))

View File

@ -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