aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-04-01 23:26:27 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-04-01 23:26:27 -0700
commit275e7903389673aa4496a15eba93207fe14f8605 (patch)
tree1b6fc03f19ac4ff539c1cbf89174b9f2fe013a1b
parent5d3453b6645e7fbc99f5817894f6f032728654e1 (diff)
downloadconsfigurator-275e7903389673aa4496a15eba93207fe14f8605.tar.gz
add FILE:LACKS-LINES
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--src/package.lisp1
-rw-r--r--src/property/file.lisp7
2 files changed, 8 insertions, 0 deletions
diff --git a/src/package.lisp b/src/package.lisp
index c533e4a..5c5623f 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -217,6 +217,7 @@
(:local-nicknames (#:re #:cl-ppcre))
(:export #:has-content
#:contains-lines
+ #:lacks-lines
#:has-mode
#:does-not-exist
#:data-uploaded
diff --git a/src/property/file.lisp b/src/property/file.lisp
index 66d8373..a959120 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -51,6 +51,13 @@ CONTENT can be a list of lines or a single string."
(deletef new-lines existing-line :test #'string=))
(writefile path (unlines (nconc existing-lines new-lines)))))))
+(defprop lacks-lines :posix (path &rest lines)
+ "If there is a file at PATH, ensure it does not contain any of LINES."
+ (:apply
+ (map-file-lines
+ path
+ (curry #'remove-if (lambda (l) (member l lines :test #'string=))))))
+
(defprop has-mode :posix (path mode)
"Ensure that a file has a particular numeric mode."
(:desc (format nil "~A has mode ~O" path mode))