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)
|
(define-module (ordo condition)
|
||||||
#:use-moudle (ordo context)
|
#:use-module (srfi srfi-71)
|
||||||
|
#:use-module (ordo context)
|
||||||
#:use-module (ordo action filesystem))
|
#:use-module (ordo action filesystem))
|
||||||
|
|
||||||
(define (cond:any preds)
|
(define-public (cond:any preds)
|
||||||
(lambda (ctx)
|
(lambda (ctx)
|
||||||
(let loop ((preds preds))
|
(let loop ((preds preds))
|
||||||
(if (null? preds)
|
(if (null? preds)
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
#t
|
#t
|
||||||
(loop (cdr preds))))))))
|
(loop (cdr preds))))))))
|
||||||
|
|
||||||
(define (cond:every preds)
|
(define-public (cond:every preds)
|
||||||
(lambda (ctx)
|
(lambda (ctx)
|
||||||
(let loop ((preds preds))
|
(let loop ((preds preds))
|
||||||
(if (null? preds)
|
(if (null? preds)
|
||||||
|
@ -22,17 +23,17 @@
|
||||||
(loop (cdr preds))
|
(loop (cdr preds))
|
||||||
#f))))))
|
#f))))))
|
||||||
|
|
||||||
(define (cond:command-available? cmd-name)
|
(define-public (cond:command-available? cmd-name)
|
||||||
(lambda (ctx)
|
(lambda (ctx)
|
||||||
(let ((_ rc) (run "which" `(,cmd-name)))
|
(let ((_ rc (run "which" `(,cmd-name))))
|
||||||
(zero? rc))))
|
(zero? rc))))
|
||||||
|
|
||||||
(define (cond:directory? path)
|
(define-public (cond:directory? path)
|
||||||
(lambda (ctx)
|
(lambda (ctx)
|
||||||
(let ((st ((action:stat path) ctx)))
|
(let ((st ((action:stat path) ctx)))
|
||||||
(and st (string=? "directory" (assoc-ref st 'file-type))))))
|
(and st (string=? "directory" (assoc-ref st 'file-type))))))
|
||||||
|
|
||||||
(define (cond:regular-file? path)
|
(define-public (cond:regular-file? path)
|
||||||
(lambda (ctx)
|
(lambda (ctx)
|
||||||
(let ((st ((action:stat path) ctx)))
|
(let ((st ((action:stat path) ctx)))
|
||||||
(and st (string=? "regular-file" (assoc-ref st 'file-type))))))
|
(and st (string=? "regular-file" (assoc-ref st 'file-type))))))
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
(use-modules
|
(use-modules
|
||||||
(ice-9 filesystem)
|
(ice-9 filesystem)
|
||||||
|
(ordo condition)
|
||||||
(ordo connection)
|
(ordo connection)
|
||||||
(ordo context )
|
(ordo context)
|
||||||
(ordo action filesystem)
|
(ordo action filesystem)
|
||||||
(ordo play)
|
(ordo play)
|
||||||
(ordo task)
|
(ordo task)
|
||||||
|
@ -18,7 +19,8 @@
|
||||||
(task "Create test directory"
|
(task "Create test directory"
|
||||||
(bind-context-vars
|
(bind-context-vars
|
||||||
(base-dir)
|
(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"
|
(task "Create test file from string content"
|
||||||
(bind-context-vars
|
(bind-context-vars
|
||||||
(base-dir)
|
(base-dir)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue