Skip to content

Instantly share code, notes, and snippets.

@aprxi
Last active September 27, 2019 20:27
Show Gist options
  • Save aprxi/14ccc84bed71b349ddaa7d6ed63a9fca to your computer and use it in GitHub Desktop.
Save aprxi/14ccc84bed71b349ddaa7d6ed63a9fca to your computer and use it in GitHub Desktop.
Makefile-fork
.PHONY: fork
FILES = \
module files Makefile Dockerfile docker-compose.yml setup.py MANIFEST.in variables .gitignore .pylintrc
DEST ?= $(dest)
fork:
ifeq ($(DEST),)
@echo 'MISSING "dest=" PARAMETER'
@echo 'RUN: make fork dest=$${DIRECTORY}'
else
@# copy when either directory does not exist, or is empty
@# skip if a non-empty directory exist
@# Note this excludes README.md and LICENSE -- you own your own project ;)
@(([ ! -d "$(DEST)" ] || find "$(DEST)" -prune -type d -empty |grep -q .) \
&& mkdir -p "$(DEST)" \
&& cp -R $(FILES) "$(DEST)/" \
&& touch $(DEST)/README.md \
|| echo "SKIPPING FORK, WON'T OVERWRITE EXISTING DIRECTORY")
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment