I'm currently trying to get some #clojuredart templates together for deps-new (https://github.com/gregorybleiker/cljd-templates). I'm facing the problem that I'd like a .gitignore file to be copied to the output directory. However, this is getting overwritten by another initialization process if I just place it in the root directory, so I need to read and append data somewhere. What is the recommended method to do this? Use regular closure/java functions in post-process-fn?
Yes, something in post-process-fn does overwrite .gitignore and that can't be helped, but I still have to modify/overwrite the file after that. So is the best way of going about this to use directly in that method or does deps-new have another mechanism to achieve this?
Well, you control the post-process code so if you want to preserve the .gitignore file that deps-new creates from your template, it seems you have a couple of choices:
• start by copying .gitignore somewhere, run the other post-process code, copy .gitignore back (overwriting whatever version the post-process code created)
• rename .gitignore in the template and let deps-new copy that to the target dir, then in post-process as the last step, copy that file over the .gitignore created by those earlier steps
deps-new gives you the post-process hook so that you can do whatever you want after deps-new has created the project from the template: you have complete control over what that hook does.
Thank you @seancorfield for clearing that up. I just wanted to make sure I'm not working against the system by doing this kind of modifications in the post-process function.
That post-process hook is very much "caveat programmer" -- but by that point, deps-new is "done" with its work.
Can you explain how you are using the template to create a new project so I can try to repro this? i.e., the actual clojure -Tnew ... command you are using...
there's a run.sh in the repo... however, the setup is a bit involved because you need flutter/dart as a prerequisite
I only need to run the clojure -Tnew ... command to generate a project. I don't need anything setup.
(I'm asking because the issue you're describing has not cropped up in deps-new template I've heard of so far, so I want to test just the project creation part)
I suspect something else you are doing is overwriting the .gitignore file..
If I comment out the three -fn items in template.edn and run this command in the dart-cli folder, it creates a project correctly with the expected .gitignore file:
clojure -Sdeps '{:paths ["resources"]}' -Tnew create :template clojuredart/cli :name user/user
So I think something in your post-process-fn is overwriting your .gitignore file.