Permalink
Browse files

fix #8 - print error if user tries to install non-existent file

  • Loading branch information...
1 parent edb482e commit 49c56b3eced0044ca9e16d3ba20912788a0901cb @kumarshantanu committed Jul 7, 2013
Showing with 16 additions and 2 deletions.
  1. +9 −2 src/leiningen/localrepo.clj
  2. +7 −0 src/leiningen/localrepo/internal.clj
@@ -27,6 +27,13 @@
(main/abort (format "ERROR: '%s' is not a directory" dir))))
+(defn assert-file
+ [^String file]
+ (if (in/file? (jio/file file))
+ file
+ (main/abort (format "ERROR: '%s' is not a file" file))))
+
+
(defn split-artifactid
"Given 'groupIp/artifactId' string split them up and return
as a vector of 2 elements."
@@ -103,8 +110,8 @@
[repo-path pom-filename filename artifact-id version]
(aether/install :local-repo (assert-dir repo-path)
:coordinates [(symbol artifact-id) version]
- :jar-file (jio/file filename)
- :pom-file pom-filename)
+ :jar-file (jio/file (assert-file filename))
+ :pom-file (assert-file pom-filename))
(main/exit 0))
@@ -97,6 +97,13 @@
(.isDirectory d)))
+(defn file?
+ "Return true if `f` is a file, false otherwise."
+ [f]
+ (and (instance? File f)
+ (.isFile f)))
+
+
(defn dir-or-file
"Return :dir if `f` (java.io.File) is a directory, :file otherwise."
[f]

0 comments on commit 49c56b3

Please sign in to comment.