-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRY up Makefile using automatic variables
- Loading branch information
Showing
1 changed file
with
10 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
.PHONY: lint check_dupes install | ||
|
||
sources :=$(wildcard ./exercises/**.json) | ||
|
||
lint: | ||
check-jsonschema --schemafile ./schema.json ./exercises/**.json | ||
check-jsonschema --schemafile ./schema.json $(sources) | ||
check_dupes: | ||
# check for duplicate id's, if there's ID's listed here | ||
# we've got duplicate id's that need to be resolved | ||
jq -s ".[]" exercises/**.json | jq '.id' | sort | uniq -d | ||
jq -s ".[]" $(sources) | jq '.id' | sort | uniq -d | ||
install: | ||
pip install check-jsonschema | ||
dist/exercises.json: ./exercises/**.json | ||
dist/exercises.json: $(sources) | ||
# requires jq | ||
# brew install jq (for macos) | ||
jq -s '.' ./exercises/**.json > ./dist/exercises.json | ||
dist/exercises.nd.json: ./exercises/**.json | ||
jq -s '.' $^ > $@ | ||
dist/exercises.nd.json: $(sources) | ||
# output to new line delimited JSON | ||
# for use to import into PostgreSQL via the COPY command | ||
# | ||
# https://konbert.com/blog/import-json-into-postgres-using-copy | ||
# https://www.postgresql.org/docs/current/sql-copy.html | ||
jq -s '.[]' ./exercises/**.json > ./dist/exercises.nd.json | ||
jq -s '.[]' $^ > $@ | ||
dist/exercises.csv: dist/exercises.json | ||
# output to csv format | ||
# requires in2csv which is part of | ||
# https://csvkit.readthedocs.io/ | ||
in2csv ./dist/exercises.json > ./dist/exercises.csv | ||
in2csv ./dist/exercises.json > $@ |