fix: lints and new scripts having same path bugs as feat/db

This commit is contained in:
Gabriel Horner
2025-03-17 12:08:44 -04:00
parent e1f7bdfa9d
commit 332b7a0825
3 changed files with 12 additions and 12 deletions

View File

@@ -7,18 +7,19 @@
[clojure.pprint :as pprint]
[clojure.string :as string]
[logseq.common.config :as common-config]
#_:clj-kondo/ignore
[logseq.db.sqlite.cli :as sqlite-cli]
[logseq.db.sqlite.export :as sqlite-export]
[nbb.core :as nbb]))
(defn- get-dir-and-db-name
"Gets dir and db name for use with open-db!"
"Gets dir and db name for use with open-db! Works for relative and absolute paths and
defaults to ~/logseq/graphs/ when no '/' present in name"
[graph-dir]
(if (string/includes? graph-dir "/")
(let [graph-dir'
(node-path/join (or js/process.env.ORIGINAL_PWD ".") graph-dir)]
((juxt node-path/dirname node-path/basename) graph-dir'))
(let [resolve-path' #(if (node-path/isAbsolute %) %
;; $ORIGINAL_PWD used by bb tasks to correct current dir
(node-path/join (or js/process.env.ORIGINAL_PWD ".") %))]
((juxt node-path/dirname node-path/basename) (resolve-path' graph-dir)))
[(node-path/join (os/homedir) "logseq" "graphs") graph-dir]))
(def spec