(ns create-reagent-app-script.core
  (:require ["fs-extra" :as fs]))

(def arguments (js->clj js/process.argv))

;; `npx create-react-app my-app --re-frame` will give us
;; options of [my-app --re-frame]
(def options (subvec arguments 2))

(def user-project-name (str (first options)))

(fs/mkdirSync "./tmp")

;; --- Run ---

(defn output! []
  (js/console.log "Platform:" js/process.platform)
  (js/console.log "Node version is:" js/process.version)
  (println arguments)
  (println options)
  (println user-project-name))

(defn ^:export main []
  (println "main")
  (output!))

(defn ^:dev/after-load reload! []
  (println "reload!")
  (output!))
