From 693d6ff8c273e0964961a0a039a353ddb2443894 Mon Sep 17 00:00:00 2001 From: Srijayanth Sridhar <131062+craftybones@users.noreply.github.com> Date: Tue, 18 Oct 2022 20:36:03 +0530 Subject: [PATCH] Fix scittle.nrepl to honor SCITTLE_NREPL_WEBSOCKET_PORT (#45) --- CHANGELOG.md | 4 ++++ src/scittle/nrepl.cljs | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b950e81..c854b63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Fix for [44](https://github.com/babashka/scittle/issues/44): Honoring `SCITTLE_NREPL_WEBSOCKET_PORT` in `scittle.nrepl` + ## v0.3.10 - Add `scittle.promesa.js` plugin. This gives access to the [promesa](https://cljdoc.org/d/funcool/promesa/8.0.450/doc/user-guide) library. diff --git a/src/scittle/nrepl.cljs b/src/scittle/nrepl.cljs index e7fcad2..fffa295 100644 --- a/src/scittle/nrepl.cljs +++ b/src/scittle/nrepl.cljs @@ -31,9 +31,12 @@ :complete (let [completions (completions (assoc msg :ctx @!sci-ctx))] (nrepl-reply msg completions)))) -(when (.-SCITTLE_NREPL_WEBSOCKET_PORT js/window) +(defn ws-url [host port path] + (str "ws://" host ":" port "/" path)) + +(when-let [ws-port (.-SCITTLE_NREPL_WEBSOCKET_PORT js/window)] (set! (.-ws_nrepl js/window) - (new js/WebSocket "ws://localhost:1340/_nrepl"))) + (new js/WebSocket (ws-url "localhost" ws-port "_nrepl")))) (when-let [ws (nrepl-websocket)] (prn :ws ws)