Fix Windows build (#171)

pull/175/head
codito 3 years ago committed by GitHub
parent e037befdf1
commit 83c15cc927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

3
.gitignore vendored

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

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

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

Loading…
Cancel
Save