-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a73759
commit b892cb5
Showing
6 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.cpcache | ||
/delegate.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{:paths ["src"] | ||
:deps | ||
{org.clojure/clojurescript {:mvn/version "1.10.597"}} | ||
:aliases {:pack | ||
{:extra-deps | ||
{pack/pack.alpha | ||
{:git/url "https://github.com/juxt/pack.alpha.git" | ||
:sha "60cdf0e75efc988b893eafe726ccdf0d5a5a6067"}} | ||
:main-opts ["-m"]}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
clojure -A:pack \ | ||
mach.pack.alpha.skinny \ | ||
--no-libs \ | ||
--project-path delegate.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mvn deploy:deploy-file \ | ||
-Dfile=delegate.jar \ | ||
-DrepositoryId=clojars \ | ||
-Durl=https://clojars.org/repo \ | ||
-DpomFile=pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>io.dominic</groupId> | ||
<artifactId>delegating-repl</artifactId> | ||
<version>0.0.2</version> | ||
<name>delegating-repl</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.clojure</groupId> | ||
<artifactId>clojure</artifactId> | ||
<version>1.10.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.clojure</groupId> | ||
<artifactId>clojurescript</artifactId> | ||
<version>1.10.597</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<sourceDirectory>src</sourceDirectory> | ||
</build> | ||
<repositories> | ||
<repository> | ||
<id>clojars</id> | ||
<url>https://repo.clojars.org/</url> | ||
</repository> | ||
</repositories> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
(ns io.dominic.delegating-repl.core | ||
(:require | ||
[cljs.repl :as repl] | ||
[clojure.java.shell :as sh])) | ||
|
||
(defrecord DelegatingEnv [delegate] | ||
repl/IJavaScriptEnv | ||
(-setup [this opts] | ||
(let [result (repl/-setup delegate opts) | ||
!exec (future (apply sh/sh (get opts :launch-command)))] | ||
(try | ||
;; Check command didn't fail within 1s, indicating some obvious | ||
;; failure. | ||
(when-let [{:keys [exit out err]} (deref !exec 1000 nil)] | ||
(when (pos? exit) | ||
(println "Failed to run launch-command: " | ||
(get opts :launch-command)) | ||
(println "STDOUT:\n" (String. out)) | ||
(println "STDERR:\n" (String. err)))) | ||
(catch Throwable t | ||
(println "Failed to run launch-command: " | ||
(get opts :launch-command)) | ||
(.printStackTrace t))) | ||
result)) | ||
(-evaluate [this filename line js] | ||
(repl/-evaluate delegate filename line js)) | ||
(-load [this provides url] | ||
(repl/-load delegate provides url)) | ||
(-tear-down [this] | ||
(repl/-tear-down delegate)) | ||
repl/IReplEnvOptions | ||
(-repl-options [this] | ||
;; TODO: Look into | ||
#_{:browser-repl true | ||
:repl-requires | ||
'[[clojure.browser.repl] [clojure.browser.repl.preload]] | ||
:cljs.cli/commands | ||
{:groups {::repl {:desc "browser REPL options"}} | ||
:init | ||
{["-H" "--host"] | ||
{:group ::repl :fn #(assoc-in %1 [:repl-env-options :host] %2) | ||
:arg "address" | ||
:doc "Address to bind"} | ||
["-p" "--port"] | ||
{:group ::repl :fn #(assoc-in %1 [:repl-env-options :port] (Integer/parseInt %2)) | ||
:arg "number" | ||
:doc "Port to bind"}}}} | ||
(repl/-repl-options delegate)) | ||
repl/IParseStacktrace | ||
(-parse-stacktrace [this st err opts] | ||
(repl/-parse-stacktrace delegate st err opts)) | ||
repl/IGetError | ||
(-get-error [this e env opts] | ||
(repl/-get-error delegate e env opts))) | ||
|
||
(defn repl-env | ||
[& {:as compiler-opts}] | ||
(let [{repl-env-f :io.dominic.delegating-repl/repl-env} | ||
compiler-opts | ||
repl-env (apply (requiring-resolve repl-env-f) | ||
(apply concat compiler-opts))] | ||
(merge (->DelegatingEnv repl-env) | ||
;; Adds any keys that things might be poking at. | ||
repl-env))) |