From 0a075aea30895dc1f2627b6d855adfb537f929aa Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sun, 22 Feb 2015 14:43:39 -0800 Subject: [PATCH] doc typo --- command.rkt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/command.rkt b/command.rkt index f503878..d565a02 100644 --- a/command.rkt +++ b/command.rkt @@ -44,15 +44,21 @@ clone copy project to desktop without source files" ,(world:curr (build-path (find-system-path 'desk-dir) (string->path world:clone-directory-name)))) `(begin - (displayln "Cloning ...") - (require racket/file pollen/file) + (require racket/file pollen/file racket/list) (define (delete-it path) (cond [(directory-exists? path) (delete-directory/files path)] [(file-exists? path) (delete-file path)])) + (define (contains-directory? possible-superdir possible-subdir) + (define (has-prefix? xs prefix) + (and (>= (length xs) (length prefix)) + (andmap equal? prefix (take xs (length prefix))))) + ((explode-path possible-subdir) . has-prefix? . (explode-path possible-superdir))) (define source-dir ,directory) - (when (not (directory-exists? source-dir)) (error (format "clone error: source directory ~a does not exist" source-dir))) + (when (not (directory-exists? source-dir)) (error 'clone (format "source directory ~a does not exist" source-dir))) (define target-dir ,target-path) + (when (source-dir . contains-directory? . target-dir) (error 'clone "aborted because target directory for cloning (~a) can't be inside source directory (~a)" target-dir source-dir)) + (displayln "Cloning ...") (when (directory-exists? target-dir) (delete-directory/files target-dir)) (copy-directory/files source-dir target-dir) (for-each delete-it (find-files pollen-related-file? target-dir))