@@ -429,18 +429,22 @@ present"
429429
430430(defn default-compile
431431 [repl-env {:keys [ns args options] :as cfg}]
432- (let [env-opts (repl/repl-options (repl-env ))
433- main-ns (when ns (symbol ns ))
432+ (let [rfs #{" -r" " --repl" }
433+ sfs #{" -s" " --serve" }
434+ env-opts (repl/repl-options (repl-env ))
435+ repl? (boolean (or (rfs ns ) (rfs (first args))))
436+ serve? (boolean (or (sfs ns ) (sfs (first args))))
437+ main-ns (if (and ns (not ((into rfs sfs) ns )))
438+ (symbol ns )
439+ (:main options))
434440 coptsf (when-let [od (:output-dir options)]
435441 (io/file od " cljsc_opts.edn" ))
436442 opts (as->
437443 (merge
438444 (when (and coptsf (.exists coptsf))
439445 (edn/read-string (slurp coptsf)))
440446 (select-keys env-opts
441- (cond-> [:target ]
442- (not (:target options))
443- (conj :browser-repl )))
447+ (cond-> [:target ] repl? (conj :browser-repl )))
444448 options
445449 (when main-ns
446450 {:main main-ns})) opts
@@ -458,8 +462,6 @@ present"
458462 cfg (update cfg :options merge (select-keys opts convey))
459463 source (when (and (= :none (:optimizations opts :none )) main-ns)
460464 (:uri (build/ns->location main-ns)))
461- repl? (boolean (#{" -r" " --repl" } (first args)))
462- serve? (boolean (#{" -s" " --serve" } (first args)))
463465 cenv (env/default-compiler-env )]
464466 (env/with-compiler-env cenv
465467 (if-let [path (:watch opts)]
@@ -562,9 +564,12 @@ present"
562564 :arg " ns"
563565 :doc " Call the -main function from a namespace with args" }
564566 [" -c" " --compile" ] {:fn compile-opt
565- :arg " ns"
566- :doc (str " Compile a namespace. If --repl present after "
567- " namespace will launch a REPL after the compile completes" )}
567+ :arg " [ns]"
568+ :doc (str " Run a compile. If optional namespace specified, use as "
569+ " the main entry point. If --repl follows, "
570+ " will launch a REPL after the compile completes. "
571+ " If --server follows, will start a web server that serves "
572+ " the current directory after the compile completes." )}
568573 [" -s" " --serve" ] {:fn serve-opt
569574 :arg " host:port"
570575 :doc (str " Start a simple web server to serve the current directory" )}
0 commit comments