Skip to content

Commit

Permalink
update for 2.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Armaldio committed Mar 14, 2019
1 parent 8f10aca commit 6f0aae7
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/preview/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"bytes"
"fmt"
"io"
"runtime"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
)

func runningPath() string {
Expand All @@ -25,15 +25,7 @@ func main() {
if len(os.Args) > 1 {
url := os.Args[1]

// fmt.Println(runningPath())

/* --- */
npm := "npm"
if runtime.GOOS == "windows" {
npm = "npm.cmd"
}

cmd := exec.Command(npm, "run", "start", "--", url)
cmd := exec.Command("efc", "preview", url)
cmd.Dir = runningPath()

var stdBuffer bytes.Buffer
Expand All @@ -44,16 +36,21 @@ func main() {

// Execute the command
if err := cmd.Run(); err != nil {
// log.Panic(err)
log.Println(err)
if strings.Contains(err.Error(), "not found") {
log.Println("Node.js and @efc/cli module must be installed before using this binary!")
} else {
log.Println(err)
}
os.Exit(0)
}

log.Println(stdBuffer.String())
/* --- */

} else {
fmt.Print("You must pass an url as first argument!")
os.Exit(0)
}
bufio.NewReader(os.Stdin).ReadBytes('\n')
_, _ = bufio.NewReader(os.Stdin).ReadBytes('\n')

}

0 comments on commit 6f0aae7

Please sign in to comment.