From 4ccf013e720d43bcf8d7c3fa240befa894a8be32 Mon Sep 17 00:00:00 2001 From: Paolo Holinski Date: Thu, 25 Jan 2024 10:31:00 +0100 Subject: [PATCH] cli: ensure files copied by template are writable --- src/nextjournal/garden_cli.clj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nextjournal/garden_cli.clj b/src/nextjournal/garden_cli.clj index 0604df0..3395b09 100755 --- a/src/nextjournal/garden_cli.clj +++ b/src/nextjournal/garden_cli.clj @@ -82,8 +82,11 @@ (fs/delete-if-exists "garden.edn")) (defn template [target-dir] - (fs/copy-tree (fs/path (io/resource "project-template")) target-dir {:replace-existing true - :posix-file-permissions "rwxr-xr-x"})) + (let [perms "rwxr-xr-x"] + (fs/copy-tree (fs/path (io/resource "project-template")) target-dir {:replace-existing true + :posix-file-permissions perms}) + (fs/walk-file-tree target-dir {:pre-visit-dir (fn [dir _] (fs/set-posix-file-permissions dir perms) :continue) + :visit-file (fn [file _] (fs/set-posix-file-permissions file perms) :continue)}))) (defn project-dir [] (fs/cwd))