Commit f9a660eb authored by Eric Timmons's avatar Eric Timmons
Browse files

call-with-bundle-local-config starts a new session to add bundle local config

parent ac6495c2
......@@ -16,6 +16,7 @@
#:clpm/log
#:clpm/repos
#:clpm/resolve
#:clpm/session
#:clpm/source
#:do-urlencode)
(:export #:bundle-clpmfile-pathname
......@@ -39,8 +40,12 @@
(defun call-with-bundle-local-config (thunk pn)
"Call THUNK in a dynamic environment that has the local config for the
clpmfile located at PN added to the config."
(with-config-file-source-added ((merge-pathnames ".clpm/bundle.conf"
(uiop:pathname-directory-pathname pn)))
;; Override because we need to invalidate any config reading that has been
;; cached. Also need to rebind *CONFIG-SOURCES* since we're going to
;; destructively modify it.
(with-clpm-session (:override t)
(config-add-file-source! (merge-pathnames ".clpm/bundle.conf"
(uiop:pathname-directory-pathname pn)))
(funcall thunk)))
(defmacro with-bundle-local-config ((&optional (clpmfile-pn '(bundle-clpmfile-pathname))) &body body)
......
......@@ -23,8 +23,7 @@
#:config-add-file-source!
#:config-table-keys
#:config-value
#:print-config
#:with-config-file-source-added)
#:print-config)
(:import-from #:cl-ppcre))
(in-package #:clpm/config)
......@@ -77,15 +76,6 @@
(config-type-p x 'config-cli-source)))
*config-sources*)))))
(defun call-with-config-file-source-added (thunk pn)
"Call THUNK with PN added to the config sources in the dynamic environment."
(let ((*config-sources* *config-sources*))
(config-add-file-source! pn)
(funcall thunk)))
(defmacro with-config-file-source-added ((pn) &body body)
`(call-with-config-file-source-added (lambda () ,@body) ,pn))
(defun clear-global-config ()
"Clear the *config-sources* variable."
(setf *config-sources* nil))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment