mirror of https://github.com/logseq/logseq
Add aliase and replace an outdated alias
Also start making node-path consistent for frontendpull/8962/head
parent
f3f6bc4f84
commit
1e9fac25e4
|
@ -52,7 +52,7 @@
|
|||
frontend.format.mldoc mldoc
|
||||
frontend.format.block block
|
||||
frontend.fs fs
|
||||
frontend.fs.bfs bfs
|
||||
frontend.fs.memory-fs memory-fs
|
||||
frontend.fs.capacitor-fs capacitor-fs
|
||||
frontend.fs.nfs nfs
|
||||
frontend.handler.extract extract
|
||||
|
@ -92,6 +92,7 @@
|
|||
frontend.util.url url-util
|
||||
frontend.util.thingatpt thingatpt
|
||||
lambdaisland.glogi log
|
||||
logseq.common.path path
|
||||
logseq.graph-parser graph-parser
|
||||
logseq.graph-parser.text text
|
||||
logseq.graph-parser.block gp-block
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
[lambdaisland.glogi :as log]
|
||||
[frontend.fs.capacitor-fs :as capacitor-fs]
|
||||
["@capawesome/capacitor-background-task" :refer [BackgroundTask]]
|
||||
["path" :as path]))
|
||||
["path" :as node-path]))
|
||||
|
||||
;;; ### Commentary
|
||||
;; file-sync related local files/dirs:
|
||||
|
@ -662,7 +662,7 @@
|
|||
(let [favorite-pages* (set favorite-pages)]
|
||||
(fn [^FileMetadata item]
|
||||
(let [path (relative-path item)
|
||||
journal-dir (path/join (config/get-journals-directory) path/sep)
|
||||
journal-dir (node-path/join (config/get-journals-directory) node-path/sep)
|
||||
journal? (string/starts-with? path journal-dir)
|
||||
journal-day
|
||||
(when journal?
|
||||
|
@ -1429,8 +1429,8 @@
|
|||
(defn- is-journals-or-pages?
|
||||
[filetxn]
|
||||
(let [rel-path (relative-path filetxn)]
|
||||
(or (string/starts-with? rel-path (path/join (config/get-journals-directory) path/sep))
|
||||
(string/starts-with? rel-path (path/join (config/get-pages-directory) path/sep)))))
|
||||
(or (string/starts-with? rel-path (node-path/join (config/get-journals-directory) node-path/sep))
|
||||
(string/starts-with? rel-path (node-path/join (config/get-pages-directory) node-path/sep)))))
|
||||
|
||||
(defn- need-add-version-file?
|
||||
"when we need to create a new version file:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns frontend.mobile.intent
|
||||
(:require ["@capacitor/filesystem" :refer [Filesystem]]
|
||||
["path" :as path]
|
||||
["path" :as node-path]
|
||||
["send-intent" :refer [^js SendIntent]]
|
||||
[clojure.pprint :as pprint]
|
||||
[clojure.set :as set]
|
||||
|
@ -62,7 +62,7 @@
|
|||
|
||||
|
||||
(defn- embed-asset-file [url format]
|
||||
(p/let [basename (path/basename url)
|
||||
(p/let [basename (node-path/basename url)
|
||||
label (-> basename util/node-path.name)
|
||||
time (date/get-current-time)
|
||||
path (editor-handler/get-asset-path basename)
|
||||
|
@ -82,14 +82,14 @@
|
|||
"Store external content with url into Logseq repo"
|
||||
[url title]
|
||||
(p/let [time (date/get-current-time)
|
||||
title (some-> (or title (path/basename url))
|
||||
title (some-> (or title (node-path/basename url))
|
||||
gp-util/safe-decode-uri-component
|
||||
util/node-path.name
|
||||
;; make the title more user friendly
|
||||
gp-util/page-name-sanity)
|
||||
path (path/join (config/get-repo-dir (state/get-current-repo))
|
||||
path (node-path/join (config/get-repo-dir (state/get-current-repo))
|
||||
(config/get-pages-directory)
|
||||
(str (js/encodeURI (fs-util/file-name-sanity title)) (path/extname url)))
|
||||
(str (js/encodeURI (fs-util/file-name-sanity title)) (node-path/extname url)))
|
||||
_ (p/catch
|
||||
(.copy Filesystem (clj->js {:from url :to path}))
|
||||
(fn [error]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
(ns frontend.util.fs
|
||||
"Misc util fns built on top of frontend.fs"
|
||||
(:require ["path" :as path]
|
||||
(:require ["path" :as node-path]
|
||||
[frontend.util :as util]
|
||||
[logseq.graph-parser.util :as gp-util]
|
||||
[clojure.string :as string]
|
||||
|
@ -34,12 +34,12 @@
|
|||
(some #(string/ends-with? path %)
|
||||
[".DS_Store" "logseq/graphs-txid.edn"])
|
||||
;; hidden directory or file
|
||||
(let [relpath (path/relative dir path)]
|
||||
(let [relpath (node-path/relative dir path)]
|
||||
(or (re-find #"/\.[^.]+" relpath)
|
||||
(re-find #"^\.[^.]+" relpath)))
|
||||
(let [path (string/lower-case path)]
|
||||
(and
|
||||
(not (string/blank? (path/extname path)))
|
||||
(not (string/blank? (node-path/extname path)))
|
||||
(not
|
||||
(some #(string/ends-with? path %)
|
||||
[".md" ".markdown" ".org" ".js" ".edn" ".css"]))))))))
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
[frontend.fs :as fs]
|
||||
[promesa.core :as p]
|
||||
["fs" :as fs-node]
|
||||
["path" :as path]))
|
||||
["path" :as node-path]))
|
||||
|
||||
(use-fixtures :once fixtures/redef-get-fs)
|
||||
|
||||
(deftest-async create-if-not-exists-creates-correctly
|
||||
;; dir needs to be an absolute path for fn to work correctly
|
||||
(let [dir (path/resolve (test-helper/create-tmp-dir))
|
||||
some-file (path/join dir "something.txt")]
|
||||
(let [dir (node-path/resolve (test-helper/create-tmp-dir))
|
||||
some-file (node-path/join dir "something.txt")]
|
||||
|
||||
(->
|
||||
(p/do!
|
||||
|
@ -29,8 +29,8 @@
|
|||
(fs-node/rmdirSync dir))))))
|
||||
|
||||
(deftest-async create-if-not-exists-does-not-create-correctly
|
||||
(let [dir (path/resolve (test-helper/create-tmp-dir))
|
||||
some-file (path/join dir "something.txt")]
|
||||
(let [dir (node-path/resolve (test-helper/create-tmp-dir))
|
||||
some-file (node-path/join dir "something.txt")]
|
||||
(fs-node/writeFileSync some-file "OLD")
|
||||
|
||||
(->
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[frontend.handler.global-config :as global-config-handler]
|
||||
[frontend.schema.handler.plugin-config :as plugin-config-schema]
|
||||
["fs" :as fs-node]
|
||||
["path" :as path]
|
||||
["path" :as node-path]
|
||||
[clojure.edn :as edn]
|
||||
[malli.generator :as mg]
|
||||
[promesa.core :as p]
|
||||
|
@ -18,17 +18,17 @@
|
|||
(defn- create-global-config-dir
|
||||
[]
|
||||
(let [dir (test-helper/create-tmp-dir "config")
|
||||
root-dir (path/dirname dir)]
|
||||
root-dir (node-path/dirname dir)]
|
||||
(reset! global-config-handler/root-dir root-dir)
|
||||
dir))
|
||||
|
||||
(defn- delete-global-config-dir
|
||||
[config-dir]
|
||||
(doseq [relative-file (fs-node/readdirSync config-dir)]
|
||||
(fs-node/unlinkSync (path/join config-dir relative-file)))
|
||||
(fs-node/unlinkSync (node-path/join config-dir relative-file)))
|
||||
(reset! global-config-handler/root-dir nil)
|
||||
(fs-node/rmdirSync config-dir)
|
||||
(fs-node/rmdirSync (path/dirname config-dir)))
|
||||
(fs-node/rmdirSync (node-path/dirname config-dir)))
|
||||
|
||||
(deftest-async add-or-update-plugin
|
||||
(let [dir (create-global-config-dir)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"Common helper fns for tests"
|
||||
(:require [frontend.handler.repo :as repo-handler]
|
||||
[frontend.db.conn :as conn]
|
||||
["path" :as path]
|
||||
["path" :as node-path]
|
||||
["fs" :as fs-node]))
|
||||
|
||||
(defonce test-db "test-db")
|
||||
|
@ -31,9 +31,9 @@ This can be called in synchronous contexts as no async fns should be invoked"
|
|||
([] (create-tmp-dir nil))
|
||||
([subdir]
|
||||
(when-not (fs-node/existsSync "tmp") (fs-node/mkdirSync "tmp"))
|
||||
(let [dir (fs-node/mkdtempSync (path/join "tmp" "unit-test-"))]
|
||||
(let [dir (fs-node/mkdtempSync (node-path/join "tmp" "unit-test-"))]
|
||||
(if subdir
|
||||
(do
|
||||
(fs-node/mkdirSync (path/join dir subdir))
|
||||
(path/join dir subdir))
|
||||
(fs-node/mkdirSync (node-path/join dir subdir))
|
||||
(node-path/join dir subdir))
|
||||
dir))))
|
||||
|
|
Loading…
Reference in New Issue