get confirmation when `raco pollen publish` wants to overwrite a directory

pull/127/head
Matthew Butterick 8 years ago
parent 580868e1f7
commit c9984455ba

@ -169,7 +169,17 @@ version print the version" (current-server-port) (make-publish-di
(error 'publish "aborted because target directory for publishing (~a) can't contain source directory (~a)" target-dir source-dir)) (error 'publish "aborted because target directory for publishing (~a) can't contain source directory (~a)" target-dir source-dir))
(when (equal? target-dir (current-directory)) (when (equal? target-dir (current-directory))
(error 'publish "aborted because target directory for publishing (~a) can't be the same as current directory (~a)" target-dir (current-directory))) (error 'publish "aborted because target directory for publishing (~a) can't be the same as current directory (~a)" target-dir (current-directory)))
(displayln (format "publishing to ~a ..." target-dir)) (display (format "publishing from ~a " source-dir))
(displayln (format "to ~a ..." target-dir))
(define do-publish-operation?
(or (not (directory-exists? target-dir))
(begin
(display (format "target directory ~a exists. Overwrite? [yes/no] " target-dir))
(case (read)
[(y yes) #t]
[else #f]))))
(cond
[do-publish-operation?
(when (directory-exists? target-dir) (when (directory-exists? target-dir)
(delete-directory/files target-dir)) (delete-directory/files target-dir))
(copy-directory/files source-dir target-dir) (copy-directory/files source-dir target-dir)
@ -177,7 +187,8 @@ version print the version" (current-server-port) (make-publish-di
(define (delete-from-publish-dir? p) (define (delete-from-publish-dir? p)
(and (omitted-path? p) (not (extra-path? p)))) (and (omitted-path? p) (not (extra-path? p))))
(for-each delete-it (find-files delete-from-publish-dir? target-dir))) (for-each delete-it (find-files delete-from-publish-dir? target-dir)))
(displayln "completed")) (displayln "publish completed")]
[else (displayln "publish aborted")]))
(define (handle-unknown command) (define (handle-unknown command)
(if (regexp-match #rx"(shit|fuck)" command) (if (regexp-match #rx"(shit|fuck)" command)

@ -1 +1 @@
1469749293 1469813715

Loading…
Cancel
Save