Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,29 @@ watch:
@find spec/ ../lua/ -name '*.lua' \
| entr make test SPEC=$(SPEC)

rename:
@if [ "$(words $(MAKECMDGOALS))" -ne 3 ]; then \
echo "Error: Incorrect number of arguments. Usage: make rename current_plugin_name new_plugin_name"; \
exit 1; \
fi;
$(eval CURRENT_NAME=$(word 2,$(MAKECMDGOALS)))
$(eval NEW_NAME=$(word 3,$(MAKECMDGOALS)))
@echo "Renaming all references from '$(CURRENT_NAME)' to $(NEW_NAME)"
# Set LC_ALL to C for compatibility
LC_ALL=C; \
# Rename in file contents, excluding the Makefile itself
for file in $$(find ../ -type f ! -path '../.git/*' ! -path './Makefile' -exec grep -Il '$(CURRENT_NAME)' {} \;); do \
sed -i "" "s/$(CURRENT_NAME)/$(NEW_NAME)/g" "$$file"; \
done
# Rename files, excluding the Makefile
for file in $$(find ../ -type f -name '*$(CURRENT_NAME)*' ! -path '../.git/*' ! -path './Makefile'); do \
mv "$$file" "$$(echo $$file | sed 's/$(CURRENT_NAME)/$(NEW_NAME)/')"; \
done
# Rename directories, excluding .git and the Makefile's directory
for dir in $$(find ../ -type d -name '*$(CURRENT_NAME)*' ! -path '../.git/*' ! -path './'); do \
mv "$$dir" "$$(echo $$dir | sed 's/$(CURRENT_NAME)/$(NEW_NAME)/')"; \
done
%:
@:

all: prepare test