Skip to content

Commit

Permalink
cursive really does not like me
Browse files Browse the repository at this point in the history
  • Loading branch information
thheller committed May 30, 2017
1 parent fc4a428 commit 4b29343
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
1 change: 1 addition & 0 deletions npm-package-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
bin/shadow-cljs.js
3 changes: 2 additions & 1 deletion npm-package-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"shadow-cljs": "./bin/shadow-cljs"
},
"dependencies": {
"shadow-cljs-jar":"^0.4.0"
"bencode": "^0.12.0",
"shadow-cljs-jar": "^0.4.0"
}
}
41 changes: 31 additions & 10 deletions src/main/shadow/cljs/npm/cli.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(ns shadow.cljs.npm.cli
(:require ["path" :as path]
["fs" :as fs]
["child_process" :as cp]))
["child_process" :as cp]
[shadow.cljs.npm.nrepl :as nrepl]))

(defn file-older-than [a b]
(let [xa (fs/statSync a)
Expand Down Expand Up @@ -56,21 +57,41 @@
(defn run [java-cmd java-args]
(cp/spawnSync java-cmd (into-array java-args) #js {:stdio "inherit"}))

(defn main [& args]
(defn try-nrepl [args]
(when (fs/existsSync ".nrepl-port")

(let [port
(-> (fs/readFileSync ".nrepl-port")
(.toString)
(js/parseInt 10))]

(nrepl/client port args)
)))

(defn try-java [args]
(let [java-args
(or (java-args-lein)
(java-args-standalone))

all-args
(into java-args args)

result
(run "java" java-args)]
(run "java" all-args)]

(if (zero? (.-status result))
true
(when (and (.-error result)
(= "ENOENT" (.. result -error -errno)))

(when (and (.-error result)
(= "ENOENT" (.. result -error -errno)))
(js/console.log "shadow-cljs - java not found, trying node-jre")

(js/console.log "shadow-cljs - java not found, trying node-jre")
(let [jre (js/require "node-jre")

(let [jre (js/require "node-jre")
result
(run (.driver jre) all-args)]
)))))

result
(run (.driver jre) java-args)]
))))
(defn main [& args]
(or (try-nrepl args)
(try-java args)))
12 changes: 12 additions & 0 deletions src/main/shadow/cljs/npm/nrepl.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns shadow.cljs.npm.nrepl
(:require-macros [cljs.core.async.macros :refer (go)])
(:require [cljs.core.async :as async]
["net" :as net]
))

(defn client [port args]
(prn [:nrepl-client port args])

(let [socket (net/connect #js {})]

true))

0 comments on commit 4b29343

Please sign in to comment.