mirror of
https://github.com/janet-lang/janet
synced 2025-08-11 00:13:47 +00:00
Add bundle/replace
Slight generalization of bundle/reinstall to allow inplace upgrades of a bundle without reinstalling all dependent bundles as well.
This commit is contained in:
parent
182170b3be
commit
88984f7ffb
@ -4275,7 +4275,7 @@
|
|||||||
"bundle name %v cannot contain path separators" bundle-name)
|
"bundle name %v cannot contain path separators" bundle-name)
|
||||||
(assert (next bundle-name) "cannot use empty bundle-name")
|
(assert (next bundle-name) "cannot use empty bundle-name")
|
||||||
(assertf (not (fexists (get-manifest-filename bundle-name)))
|
(assertf (not (fexists (get-manifest-filename bundle-name)))
|
||||||
"bundle %v is already installed" bundle-name)
|
"bundle %v is already installed" bundle-name)
|
||||||
# Setup installed paths
|
# Setup installed paths
|
||||||
(prime-bundle-paths)
|
(prime-bundle-paths)
|
||||||
(os/mkdir (bundle-dir bundle-name))
|
(os/mkdir (bundle-dir bundle-name))
|
||||||
@ -4348,14 +4348,15 @@
|
|||||||
(spit install-hook b))
|
(spit install-hook b))
|
||||||
dest-dir)
|
dest-dir)
|
||||||
|
|
||||||
(defn bundle/reinstall
|
(defn bundle/replace
|
||||||
"Reinstall an existing bundle from the local source code."
|
"Reinstall an existing bundle from a new directory. Similar to bundle/reinstall,
|
||||||
[bundle-name &keys new-config]
|
but installs the replacement bundle from any directory. This is necesarry to replace a package without
|
||||||
|
breaking any dependencies."
|
||||||
|
[bundle-name path &keys new-config]
|
||||||
(def manifest (bundle/manifest bundle-name))
|
(def manifest (bundle/manifest bundle-name))
|
||||||
(def path (get manifest :local-source))
|
|
||||||
(def config (get manifest :config @{}))
|
(def config (get manifest :config @{}))
|
||||||
(def s (sep))
|
(def s (sep))
|
||||||
(assert (= :directory (os/stat path :mode)) "local source not available")
|
(assertf (= :directory (os/stat path :mode)) "local source %v not available" path)
|
||||||
(def backup-dir (string (dyn *syspath*) s bundle-name ".backup"))
|
(def backup-dir (string (dyn *syspath*) s bundle-name ".backup"))
|
||||||
(rmrf backup-dir)
|
(rmrf backup-dir)
|
||||||
(def backup-bundle-source (bundle/pack bundle-name backup-dir true))
|
(def backup-bundle-source (bundle/pack bundle-name backup-dir true))
|
||||||
@ -4368,6 +4369,14 @@
|
|||||||
(rmrf backup-bundle-source)
|
(rmrf backup-bundle-source)
|
||||||
bundle-name)
|
bundle-name)
|
||||||
|
|
||||||
|
(defn bundle/reinstall
|
||||||
|
"Reinstall an existing bundle from the local source code."
|
||||||
|
[bundle-name &keys new-config]
|
||||||
|
(def manifest (bundle/manifest bundle-name))
|
||||||
|
(def path (get manifest :local-source))
|
||||||
|
(bundle/replace bundle-name path ;(kvs new-config))
|
||||||
|
bundle-name)
|
||||||
|
|
||||||
(defn bundle/add-directory
|
(defn bundle/add-directory
|
||||||
"Add a directory during the install process relative to `(dyn *syspath*)`"
|
"Add a directory during the install process relative to `(dyn *syspath*)`"
|
||||||
[manifest dest &opt chmod-mode]
|
[manifest dest &opt chmod-mode]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user