Skip to content

Commit 2ed2ebe

Browse files
committed
feat: Handle local archive better
1 parent 04a75c8 commit 2ed2ebe

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

lisp/_prepare.el

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ Arguments FNC and ARGS are used for advice `:around'."
474474
(url (format "https://raw.githubusercontent.com/emacs-eask/archives/master/%s/" name))
475475
(url-file (concat url file))
476476
(download-p)
477-
(local-archive-p (string= name "local")) ; exclude local elpa
477+
;; exclude local elpa
478+
(local-archive-p (string= name eask--local-archive-name))
478479
(fmt (eask--action-format (length package-archives))))
479480
(unless (file-exists-p local-file)
480481
(eask-with-verbosity-override 'log
@@ -1442,6 +1443,10 @@ argument COMMAND."
14421443
(defun eask-f-source (name &optional location)
14431444
"Add archive NAME with LOCATION."
14441445
(when (symbolp name) (setq name (eask-2str name))) ; ensure to string, accept symbol
1446+
;; Handle local archive.
1447+
(when (equal name eask--local-archive-name)
1448+
(eask-error "Invalid archive name `%s'" name))
1449+
;; Handle multiple same archive name!
14451450
(when (assoc name package-archives)
14461451
(eask-error "Multiple definition of source `%s'" name))
14471452
(setq location (eask-source-url name location))
@@ -1456,18 +1461,28 @@ argument COMMAND."
14561461
(defvar eask-depends-on-recipe-p nil
14571462
"Set to t if package depends on recipe.")
14581463

1464+
(defvar eask--local-archive-name "local"
1465+
"The local archive name.")
1466+
14591467
(defun eask--setup-dependencies ()
14601468
"Setup dependencies list."
14611469
(setq eask-depends-on (reverse eask-depends-on)
14621470
eask-depends-on-dev (reverse eask-depends-on-dev))
14631471
(when eask-depends-on-recipe-p
14641472
(eask-with-progress
1465-
"✓ Checking local archives... "
1473+
(format "✓ Checking local archives %s... "
1474+
(ansi-magenta eask--local-archive-name))
14661475
(eask-with-verbosity 'debug
1467-
(add-to-list 'package-archives `("local" . ,github-elpa-archive-dir) t)
1468-
;; If the local archives is added, we set the priority to a very
1469-
;; high number so user we always use the specified dependencies!
1470-
(add-to-list 'package-archive-priorities `("local" . 90) t))
1476+
;; Make sure can be customized by `source'
1477+
(unless (assoc eask--local-archive-name package-archives)
1478+
(add-to-list 'package-archives
1479+
`(,eask--local-archive-name . ,github-elpa-archive-dir) t))
1480+
;; Make sure can be customized by `source-priority'
1481+
(unless (assoc eask--local-archive-name package-archive-priorities)
1482+
;; If the local archives is added, we set the priority to a very
1483+
;; high number so user we always use the specified dependencies!
1484+
(add-to-list 'package-archive-priorities
1485+
`(,eask--local-archive-name . 90) t)))
14711486
"done!")))
14721487

14731488
(add-hook 'eask-file-loaded-hook #'eask--setup-dependencies)

test/jest/__snapshots__/analyze.test.js.snap

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ exports[`analyze in ./dsl matches snapshot 1`] = `
1414
~/Eask:28:61 Error: Run-script with the same key name is not allowed: \`test\`
1515
~/Eask:31:13 Error: Multiple definition of source \`gnu'
1616
~/Eask:33:24 Error: Unknown package archive \`magic-archive'
17-
~/Eask:36:20 Error: Define dependencies with the same name \`emacs'
18-
~/Eask:39:19 Error: Define dependencies with the same name \`dash'
19-
~/Eask:44:2 Error: Define dependencies with the same name \`f'
17+
~/Eask:35:15 Error: Invalid archive name \`local'
18+
~/Eask:35:15 Error: Unknown package archive \`local'
19+
~/Eask:38:20 Error: Define dependencies with the same name \`emacs'
20+
~/Eask:41:19 Error: Define dependencies with the same name \`dash'
21+
~/Eask:46:2 Error: Define dependencies with the same name \`f'
2022
",
2123
"stdout": "",
2224
}

test/jest/dsl/Eask

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
(source 'gnu) ; duplicate archives
3131
(source 'gnu)
3232

33-
(source "magic-archive") ; Unkown archive
33+
(source "magic-archive") ; unkown archive
34+
35+
(source 'local) ; inavlid local archive
3436

3537
(depends-on "emacs" "26.1") ; duplicate `emacs` dependency
3638
(depends-on "emacs")

0 commit comments

Comments
 (0)