Test (and bugfix) conditions
This commit is contained in:
parent
875ce167e9
commit
dba8ca3153
2 changed files with 12 additions and 9 deletions
|
@ -1,8 +1,9 @@
|
|||
(define-module (ordo condition)
|
||||
#:use-moudle (ordo context)
|
||||
#:use-module (srfi srfi-71)
|
||||
#:use-module (ordo context)
|
||||
#:use-module (ordo action filesystem))
|
||||
|
||||
(define (cond:any preds)
|
||||
(define-public (cond:any preds)
|
||||
(lambda (ctx)
|
||||
(let loop ((preds preds))
|
||||
(if (null? preds)
|
||||
|
@ -12,7 +13,7 @@
|
|||
#t
|
||||
(loop (cdr preds))))))))
|
||||
|
||||
(define (cond:every preds)
|
||||
(define-public (cond:every preds)
|
||||
(lambda (ctx)
|
||||
(let loop ((preds preds))
|
||||
(if (null? preds)
|
||||
|
@ -22,17 +23,17 @@
|
|||
(loop (cdr preds))
|
||||
#f))))))
|
||||
|
||||
(define (cond:command-available? cmd-name)
|
||||
(define-public (cond:command-available? cmd-name)
|
||||
(lambda (ctx)
|
||||
(let ((_ rc) (run "which" `(,cmd-name)))
|
||||
(let ((_ rc (run "which" `(,cmd-name))))
|
||||
(zero? rc))))
|
||||
|
||||
(define (cond:directory? path)
|
||||
(define-public (cond:directory? path)
|
||||
(lambda (ctx)
|
||||
(let ((st ((action:stat path) ctx)))
|
||||
(and st (string=? "directory" (assoc-ref st 'file-type))))))
|
||||
|
||||
(define (cond:regular-file? path)
|
||||
(define-public (cond:regular-file? path)
|
||||
(lambda (ctx)
|
||||
(let ((st ((action:stat path) ctx)))
|
||||
(and st (string=? "regular-file" (assoc-ref st 'file-type))))))
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
(use-modules
|
||||
(ice-9 filesystem)
|
||||
(ordo condition)
|
||||
(ordo connection)
|
||||
(ordo context )
|
||||
(ordo context)
|
||||
(ordo action filesystem)
|
||||
(ordo play)
|
||||
(ordo task)
|
||||
|
@ -18,7 +19,8 @@
|
|||
(task "Create test directory"
|
||||
(bind-context-vars
|
||||
(base-dir)
|
||||
(action:install-dir base-dir)))
|
||||
(action:install-dir base-dir))
|
||||
#:condition (bind-context-vars (base-dir) (negate (cond:directory? base-dir))))
|
||||
(task "Create test file from string content"
|
||||
(bind-context-vars
|
||||
(base-dir)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue