on master help sign in
prybar-elisp: Automatically use Cask if available
commit01a49cc0c095f37c0d6ab52810d107ff244bd655 authorRadon Rosborough <radon.neon@gmail.com> dateWed 24 Jul 2019, 10:14 (7 years ago) parent60050b5
2 files changed+29−11
languages/elisp/main.go+21−11 scripts/docker-install.sh+8
languages/elisp/main.go+21−11
@@ -2,23 +2,24 @@ package main
22
33import (
44 "fmt"
5− "github.com/replit/prybar/utils"
65 "os"
76 "os/exec"
87 "path/filepath"
98 "syscall"
9+
10+ "github.com/replit/prybar/utils"
1011)
1112
1213func Execute(config *utils.Config) {
14+ args := []string{}
1315
14− emacs, err := exec.LookPath("emacs")
15−
16− if err != nil {
17− panic(err)
16+ if _, err := os.Stat("Cask"); err == nil {
17+ if _, err := exec.LookPath("cask"); err == nil {
18+ args = append(args, "cask", "exec")
19+ }
1820 }
1921
2022 execPath, err := os.Executable()
21−
2223 if err != nil {
2324 panic(err)
2425 }
@@ -26,6 +27,11 @@ func Execute(config *utils.Config) {
2627 runDir := filepath.Dir(execPath)
2728 replPath := filepath.Join(runDir, "prybar_assets", "elisp", "repl.el")
2829
30+ args = append(
31+ args, "emacs", "-nw", "-Q", "--load", replPath,
32+ "--eval", "(prybar-repl)",
33+ )
34+
2935 os.Setenv("PRYBAR_EVAL", config.Exp)
3036 os.Setenv("PRYBAR_EXEC", config.Code)
3137 os.Setenv("PRYBAR_PS1", config.Ps1)
@@ -45,18 +51,22 @@ func Execute(config *utils.Config) {
4551 }
4652
4753 if !(config.Interactive || config.OurInteractive) {
48− fmt.Fprintln(os.Stderr, "prybar-elisp: warn: non-interactive mode not implemented");
54+ fmt.Fprintln(os.Stderr, "prybar-elisp: warn: non-interactive mode not implemented")
4955 }
5056
5157 if config.Ps2 != "... " {
52− fmt.Fprintln(os.Stderr, "prybar-elisp: warn: ps2 not implemented");
58+ fmt.Fprintln(os.Stderr, "prybar-elisp: warn: ps2 not implemented")
5359 }
5460
55− args := []string{"emacs", "-nw", "-Q", "--load", replPath, "--eval", "(prybar-repl)"}
56− err = syscall.Exec(emacs, args, os.Environ())
61+ path, err := exec.LookPath(args[0])
62+ if err != nil {
63+ fmt.Fprintf(os.Stderr, "%s: command not found\n", args[0])
64+ }
5765
66+ err = syscall.Exec(path, args, os.Environ())
5867 if err != nil {
59− panic(err)
68+ fmt.Fprintf(os.Stderr, "failed to exec %s: %s\n", path, err)
69+ os.Exit(1)
6070 }
6171
6272}
scripts/docker-install.sh+8
@@ -32,6 +32,7 @@ libffi-dev
3232libnspr4-dev
3333
3434# used during installation
35+git
3536wget
3637
3738"
@@ -58,4 +59,11 @@ wget -nv https://launchpadlibrarian.net/309343864/libmozjs185-dev_1.8.5-1.0.0+df
5859dpkg -i *.deb
5960rm *.deb
6061
62+# prybar-elisp has support for automatically running inside a Cask
63+# environment if there is a Cask file in the working directory. Might
64+# as well install Cask so it's easy to test.
65+git clone https://github.com/cask/cask.git /usr/local/cask
66+ln -s /usr/local/cask/bin/cask /usr/local/bin/cask
67+cask upgrade-cask
68+
6169rm /tmp/docker-install.sh