8000 disable --output; move :expansion to compiler · repos-javascript-compilers/wisp@6abfcd4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6abfcd4

Browse files
committed
disable --output; move :expansion to compiler
1 parent 493da2f commit 6abfcd4

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/compiler.wisp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
(:require [wisp.analyzer :refer [analyze]]
33
[wisp.reader :refer [read* read push-back-reader]]
44
[wisp.string :refer [replace]]
5-
[wisp.sequence :refer [map conj cons vec first rest empty? count]]
5+
[wisp.sequence :refer [map reduce conj cons vec first rest empty? count]]
66
[wisp.runtime :refer [error?]]
7-
[wisp.ast :refer [name]]
7+
[wisp.ast :refer [pr-str name]]
88

99
[wisp.backend.escodegen.generator :refer [generate]
1010
:rename {generate generate-js}]
@@ -82,9 +82,15 @@
8282
(:ast ast))))
8383
(catch error {:error error})))
8484

85+
expansion (if (identical? :expansion (:print options))
86+
(reduce (fn [result item]
87+
(str result (pr-str (.-form item)) "\n"))
88+
"" (.-ast ast)))
89+
8590
result {:source-uri source-uri
8691
:ast (:ast ast)
87-
:forms (:forms forms)}]
92+
:forms (:forms forms)
93+
:expansion expansion}]
8894
(conj options output result))))
8995

9096
(defn evaluate

src/wisp.wisp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
output (compile source options)
4040
content (cond
4141
(= channel :code) (:code output)
42-
(= channel :expansion) (reduce (fn [result item]
43-
(str result (pr-str (.-form item)) "\n"))
44-
"" (.-ast output))
42+
(= channel :expansion) (:expansion output)
4543
:else (JSON.stringify (get output channel) 2 2))]
4644
(if (and (:output options) (:source-uri options) content)
4745
(writeFileSync (path.join (.-output options) ;; `join` relies on `path`
@@ -83,7 +81,7 @@
8381
(.option "-c, --compile" "Compile to JavaScript and save as .js files")
8482
(.option "-i, --interactive" "Run an interactive wisp REPL")
8583
(.option "--debug, --print <type>" "Print debug information. Possible values are `expansion`,`forms`, `ast` and `js-ast`")
86-
(.option "-o, --output <dir>" "Output to specified directory")
84+
;(.option "-o, --output <dir>" "Output to specified directory")
8785
(.option "--no-map" "Disable source map generation")
8886
(.parse process.argv))
8987
(set! (aget options "no-map") (not (aget options "map"))) ;; commander auto translates to camelCase

0 commit comments

Comments
 (0)
0