Skip to content

Commit

Permalink
Support :init option in repl api (babashka#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaidetree authored Mar 8, 2023
1 parent b9c2631 commit 6a1ff76
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ For a list of breaking changes, check [here](#breaking-changes).

[Nbb](https://github.com/babashka/nbb): Scripting in Clojure on Node.js using [SCI](https://github.com/babashka/sci)

## 1.2.170

- [#315](https://github.com/babashka/nbb/issues/315): support `:init` option in repl api

## 1.2.169 (2023-02-25)

- [#312](https://github.com/babashka/nbb/issues/312): same as [#311](https://github.com/babashka/nbb/issues/311) but with `$default`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nbb",
"version": "1.2.169",
"version": "1.2.170",
"type": "module",
"main": "index.mjs",
"bin": {
Expand Down
3 changes: 2 additions & 1 deletion src/nbb/impl/repl.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@

(defn repl
([] (repl nil))
([_opts]
([opts]
(when tty (.setRawMode js/process.stdin true))
(let [eval-require (fn
[ns-form]
Expand All @@ -200,6 +200,7 @@
(->
(eval-require ns1)
(.then (fn [] (eval-require ns2)))
(.then (:init opts identity))
(.then (fn []
(js/Promise. (fn [resolve]
(input-loop nil resolve)))))))))
Expand Down
4 changes: 4 additions & 0 deletions test-scripts/repl-init-test/init-test.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(require '[nbb.repl :as repl])

(repl/repl
{:init #(apply require '[[promesa.core :as p]])})
5 changes: 5 additions & 0 deletions test-scripts/repl-init-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"nbb": "file:../.."
}
}

0 comments on commit 6a1ff76

Please sign in to comment.