Skip to content

Instantly share code, notes, and snippets.

@excavador
Last active July 6, 2017 23:18
Show Gist options
  • Save excavador/e7880ab5cd9d93043eaa13a40edf8fed to your computer and use it in GitHub Desktop.
Save excavador/e7880ab5cd9d93043eaa13a40edf8fed to your computer and use it in GitHub Desktop.
➜ make/02.files-go-source.sh | XARGS_STATE=bin/make/fmt XARGS_WRAP_OUTPUT=0 bin/xargs-if-changed bin/gofmt -l -s -w
/Users/oleg/pp/backend/src/cmd/make/xargs-if-changed/main.go
➜ bin/xargs-if-changed --help
Usage: xargs-if-changed <tool with arguments>
tool
1. reads file paths from stdin
2. reads content of every file and calculate MD5
3. checks MD5 for this file in <XARGS_STATE>
4. if file was changed executes "<tool with arguments> <file path>"
5. if execution was successfull writes actual MD5 for <file path> to <XARGS_STATE>
environment variables:
XARGS_STATE <file path> path to file with state
XARGS_WRAP_OUTPUT <0|1> wrap or not <tool> stdout/stderr by prefix "<file>: "
XARGS_PARALLEL <integer> worker count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment