forked from squint-cljs/squint
-
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.
Beginnings of a Node REPL (squint-cljs#211)
- Loading branch information
Showing
10 changed files
with
336 additions
and
362 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 |
---|---|---|
|
@@ -37,3 +37,4 @@ jobs: | |
run: | | ||
npm install | ||
bb test | ||
bb bb/node_repl_test.clj |
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 |
---|---|---|
|
@@ -20,3 +20,4 @@ scratch.cljs | |
.vscode | ||
.nrepl-port | ||
examples/quickjs/hello | ||
.repl |
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,31 @@ | ||
(ns node-repl-test | ||
(:require | ||
[babashka.fs :as fs] | ||
[babashka.process :as p :refer [process]] | ||
[clojure.string :as str] | ||
[clojure.test :as t :refer [deftest is]])) | ||
|
||
(defn repl-process | ||
[input dir opts] | ||
(process (into ["node" (str (fs/absolutize "node_cli.js")) "repl"] (:cmd opts)) | ||
(merge {:dir (or dir ".") | ||
:out :string | ||
:in input | ||
:err :inherit} | ||
opts))) | ||
|
||
(defn repl | ||
([input] (repl input nil)) | ||
([input dir] (repl input dir nil)) | ||
([input dir opts] | ||
(-> (repl-process input dir opts) | ||
p/check))) | ||
|
||
(deftest repl-test | ||
(is (str/includes? (:out (repl "(+ 1 2 3)")) "6\n"))) | ||
|
||
(when (= *file* (System/getProperty "babashka.file")) | ||
(let [{:keys [fail error]} | ||
(t/run-tests 'node-repl-test)] | ||
(when (pos? (+ fail error)) | ||
(System/exit 1)))) |
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
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
Oops, something went wrong.