Added Firefox paths for Windows and OSX

Also updated Gopkg dep versions.

And version bump to 1.0.0pre1!
This commit is contained in:
Thomas Buckley-Houston 2018-06-10 20:16:28 +08:00
parent 7d3620e12d
commit 98fa8014b9
4 changed files with 44 additions and 21 deletions

18
interfacer/Gopkg.lock generated
View file

@ -11,7 +11,7 @@
branch = "master"
name = "github.com/gdamore/tcell"
packages = [".","terminfo"]
revision = "2548ddfbd80a92e96bdde663cdb77b56d65e7dd9"
revision = "b3cebc399d6f98536af845ed8a5144ab586f6759"
[[projects]]
name = "github.com/go-errors/errors"
@ -26,10 +26,10 @@
version = "v1.2.0"
[[projects]]
branch = "master"
name = "github.com/lucasb-eyer/go-colorful"
packages = ["."]
revision = "231272389856c976b7500c4fffcc52ddf06ff4eb"
revision = "345fbb3dbcdb252d9985ee899a84963c0fa24c82"
version = "v1.0"
[[projects]]
name = "github.com/mattn/go-runewidth"
@ -40,14 +40,14 @@
[[projects]]
name = "github.com/onsi/ginkgo"
packages = [".","config","internal/codelocation","internal/containernode","internal/failer","internal/leafnodes","internal/remote","internal/spec","internal/spec_iterator","internal/specrunner","internal/suite","internal/testingtproxy","internal/writer","reporters","reporters/stenographer","reporters/stenographer/support/go-colorable","reporters/stenographer/support/go-isatty","types"]
revision = "9eda700730cba42af70d53180f9dcce9266bc2bc"
version = "v1.4.0"
revision = "fa5fabab2a1bfbd924faf4c067d07ae414e2aedf"
version = "v1.5.0"
[[projects]]
name = "github.com/onsi/gomega"
packages = [".","format","internal/assertion","internal/asyncassertion","internal/oraclematcher","internal/testingtsupport","matchers","matchers/support/goraph/bipartitegraph","matchers/support/goraph/edge","matchers/support/goraph/node","matchers/support/goraph/util","types"]
revision = "003f63b7f4cff3fc95357005358af2de0f5fe152"
version = "v1.3.0"
revision = "62bff4df71bdbc266561a0caee19f0594b17c240"
version = "v1.4.0"
[[projects]]
branch = "master"
@ -59,13 +59,13 @@
branch = "master"
name = "golang.org/x/net"
packages = ["html","html/atom","html/charset"]
revision = "b3c676e531a6dc479fa1b35ac961c13f5e2b4d2e"
revision = "1e491301e022f8f977054da4c2d852decd59571f"
[[projects]]
branch = "master"
name = "golang.org/x/sys"
packages = ["unix"]
revision = "1d206c9fa8975fb4cf00df1dc8bf3283dc24ba0e"
revision = "9527bec2660bd847c050fda93a0f0c6dee0800bb"
[[projects]]
name = "golang.org/x/text"

View file

@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"runtime"
"path/filepath"
"strings"
"unicode"
@ -87,8 +88,10 @@ func Shutdown(err error) {
exitCode = 1
println(err.Error())
}
out := err.(*errors.Error).ErrorStack()
Log(fmt.Sprintf(out))
if *isDebug {
out := err.(*errors.Error).ErrorStack()
Log(fmt.Sprintf(out))
}
os.Exit(exitCode)
}
@ -133,14 +136,16 @@ func stripWhitespace(str string) string {
}, str)
}
// Shell ... Nice and easy shell commands
// Shell provides nice and easy shell commands
func Shell(command string) string {
parts := strings.Fields(command)
head := parts[0]
parts = parts[1:len(parts)]
out, err := exec.Command(head, parts...).Output()
out, err := exec.Command(head, parts...).CombinedOutput()
if err != nil {
return "firefox not found"
fmt.Printf(
"Browsh tried to run `%s` but failed with: %s", command, string(out))
Shutdown(err)
}
return stripWhitespace(string(out))
}
@ -176,7 +181,11 @@ func toInt32(char string) int32 {
func ttyEntry() {
// Hack to force true colours
// Follow: https://github.com/gdamore/tcell/pull/183
os.Setenv("TERM", "xterm-truecolor")
if runtime.GOOS != "windows" {
// On windows this generates a "character set not supported" error. The error comes
// from tcell.
os.Setenv("TERM", "xterm-truecolor")
}
realScreen, err := tcell.NewScreen()
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)

View file

@ -8,6 +8,7 @@ import (
"net"
"os"
"os/exec"
"runtime"
"strings"
"time"
@ -52,10 +53,7 @@ var (
func startHeadlessFirefox() {
Log("Starting Firefox in headless mode")
firefoxPath := Shell("which " + *firefoxBinary)
if _, err := os.Stat(firefoxPath); os.IsNotExist(err) {
Shutdown(errors.New("Firefox command not found: " + *firefoxBinary))
}
ensureFirefoxBinary()
args := []string{"--marionette"}
if !*isFFGui {
args = append(args, "--headless")
@ -83,6 +81,22 @@ func startHeadlessFirefox() {
}
}
func ensureFirefoxBinary() {
if *firefoxBinary == "firefox" {
switch runtime.GOOS {
case "windows":
*firefoxBinary = `c:\Program Files (x86)\Mozilla Firefox\firefox.exe`
case "darwin":
*firefoxBinary = "/Applications/Firefox.app/Contents/MacOS/firefox"
default:
*firefoxBinary = Shell("which firefox")
}
}
if _, err := os.Stat(*firefoxBinary); os.IsNotExist(err) {
Shutdown(errors.New("Firefox binary not found: " + *firefoxBinary))
}
}
// Start Firefox via the `web-ext` CLI tool. This is for development and testing,
// because I haven't been able to recreate the way `web-ext` injects an unsigned
// extension.
@ -96,7 +110,7 @@ func startWERFirefox() {
"--no-reload",
"--url=https://www.google.com",
}
firefoxProcess := exec.Command(rootDir+"/webext/node_modules/.bin/web-ext", args...)
firefoxProcess := exec.Command(rootDir + "/webext/node_modules/.bin/web-ext", args...)
firefoxProcess.Dir = rootDir + "/webext/dist/"
defer firefoxProcess.Process.Kill()
stdout, err := firefoxProcess.StdoutPipe()

View file

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Browsh",
"version": "0.2.14",
"version": "1.0.0",
"description": "Renders the browser as realtime, interactive, TTY-compatible text",