:working-directory option to specify the working directory for Node.js #12

Merged
merged 1 commit into from Dec 11, 2015

Projects

None yet

2 participants

@eploko
Contributor
eploko commented Dec 2, 2015

This adds the option mentioned in pupeno/prerenderer#11

@pupeno pupeno commented on the diff Dec 3, 2015
src/clj/prerenderer/core.clj
@@ -70,10 +74,13 @@
.deleteOnExit))
:start-timeout 5000
:wait false
- :noop-when-stopped false}
+ :noop-when-stopped false
+ :working-directory "."}
@pupeno
pupeno Dec 3, 2015 Owner

I'm just wondering, should :working-directory be "." by default or should it be nil and have the old behaviour in that case? What do you think?

Otherwise, is "." cross platform?

@eploko
eploko Dec 12, 2015 Contributor

"." should work fine at least on any bsd/linux/osx/windows. I'd leave it as is and fix if any issues arise, which I doubt would happen.

@pupeno pupeno commented on the diff Dec 3, 2015
src/clj/prerenderer/core.clj
@@ -10,16 +10,19 @@
(defn ensure-javascript-exists
([js-engine] (ensure-javascript-exists js-engine false))
([js-engine notify-about-file-appearing]
- (if (not (.exists (io/as-file (:path js-engine))))
- (let [message (str "File " (:path js-engine) " for prerendering is not present. Did you compile your JavaScript? 'lein cljsbuild auto' maybe?")]
- (if (:wait js-engine)
- (do
- (println message "Waiting until it appears...")
- (Thread/sleep 100)
- (recur js-engine true))
- (throw (Exception. message))))
- (when notify-about-file-appearing
- (println "File" (:path js-engine) "appeared. Pfiuuu!")))))
+ (let [path (:path js-engine)
+ working-directory (:working-directory js-engine ".")
+ full-path (.getAbsolutePath (java.io.File. working-directory path))]
@pupeno
pupeno Dec 3, 2015 Owner

Are there any chances of getAbsolutePath failing or giving surprising results here?

@eploko
eploko Dec 12, 2015 Contributor

None that I'm aware of.

@pupeno pupeno merged commit e0a0775 into pupeno:master Dec 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment