improve handling of relative directories as input to `raco pollen render`

pull/58/head
Matthew Butterick 10 years ago
parent 0216df6c86
commit c0f7f5fb82

@ -10,8 +10,9 @@
help show this message
start [dir] [port] starts project server in dir (default is current dir)
(default port is ~a)
render [dir] render project in dir (default is current dir)
render path render file
render [dir] [dest] render project in dir (default is current dir)
to dest (default is desktop)
render filename render filename only (can be source or output name)
clone copy project to desktop without source files" ,(world:current-server-port))))
(define (handle-render dir-or-path rest-args)
@ -61,15 +62,15 @@ clone copy project to desktop without source files" ,(world:curr
(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)
(define source-dir (simplify-path ,directory))
(when (not (directory-exists? source-dir)) (error 'clone (format "source directory ~a does not exist" source-dir)))
(define target-dir ,target-path)
(define target-dir (simplify-path ,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))
(displayln (format "Completed to ~a" ,target-path))))
(displayln (format "Completed to ~a" target-dir))))
(define (handle-else command)
`(if (regexp-match #rx"(shit|fuck)" ,command)

Loading…
Cancel
Save