File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 113113 {:ok? true
114114 :dir (:destination-dir action)
115115 :file (:destination-file action)}
116+ (let [env-home (or (some-> js/process .-env .-HOME)
117+ (some-> js/process .-env .-USERPROFILE))]
116118 (resolve-install-target {:global? (:global? action)
117119 :cwd (.cwd js/process)
118- :home-dir (.homedir os)})))
120+ :home-dir (or env-home
121+ (.homedir os))}))))
119122
120123(defn execute-skill-install
121124 [action _config]
Original file line number Diff line number Diff line change 139139 (finally
140140 (fs/rmSync tmp-root #js {:recursive true :force true })))))
141141
142+ (deftest test-execute-skill-install-global-prefers-home-env
143+ (let [tmp-root (.mkdtempSync fs (node-path/join (.tmpdir os) " logseq-skill-home-" ))
144+ source-path (node-path/join tmp-root " source-skill.md" )
145+ installed-file (node-path/join tmp-root " .agents" " skills" " logseq-cli" " SKILL.md" )
146+ previous-home (.. js/process -env -HOME)]
147+ (try
148+ (fs/writeFileSync source-path " # installed\n content" " utf8" )
149+ (set! (.. js/process -env -HOME) tmp-root)
150+ (let [result (skill-command/execute-skill-install {:type :skill-install
151+ :source-path source-path
152+ :global? true }
153+ {})]
154+ (is (= :ok (:status result)))
155+ (is (= installed-file (get-in result [:data :installed-path ])))
156+ (is (= " # installed\n content" (fs/readFileSync installed-file " utf8" ))))
157+ (finally
158+ (if (some? previous-home)
159+ (set! (.. js/process -env -HOME) previous-home)
160+ (js-delete (.-env js/process) " HOME" ))
161+ (fs/rmSync tmp-root #js {:recursive true :force true })))))
162+
142163(deftest test-execute-skill-install-write-error
143164 (let [mkdir-sync (.-mkdirSync fs)
144165 write-file-sync (.-writeFileSync fs)
You can’t perform that action at this time.
0 commit comments