-
Notifications
You must be signed in to change notification settings - Fork 12
/
repo.clj
30 lines (25 loc) · 1.19 KB
/
repo.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(ns metav.repo
(:require [metav.git :as git :refer [pwd]]
[me.raynes.fs :as fs]))
(def module-build-file "deps.edn")
(defn monorepo?
"Does a single repo contains several modules? (dir with a build config like deps.edn in it). A monorepo is detected when the metav library is invoked correctly in a subdirectory of a git repo
(so a deps.edn file is present in a subdirectory) "
([] (monorepo? (pwd)))
([dir]
(boolean (or (and (= (fs/normalized (fs/file dir))
(fs/normalized (fs/file (git/toplevel dir))))
(> (count (fs/find-files dir #"deps.edn")) 1))
(and (not (nil? (git/prefix dir)))
(fs/file? (if dir
(str dir "/" module-build-file)
module-build-file)))))))
(defn dedicated-repo?
"Does the current working directory contains a build system for a module (like deps.edn)"
([] (dedicated-repo? (pwd)))
([repo-dir]
;;assume the working dir contains a deps.edn
(and (nil? (git/prefix repo-dir))
(fs/file? (if repo-dir
(str repo-dir "/" module-build-file)
module-build-file)))))