No sed backup file

This commit is contained in:
Rod Vagg 2024-02-15 08:29:39 +11:00
parent acdc19817e
commit 91fd0ec101

View File

@ -1,17 +1,22 @@
#!/usr/bin/env bash #!/usr/bin/env bash
sed_replace='/import (/ {
:1
$!N
s/\n\n/\'$'\n''/
/)/!b1
}'
go_files() { go_files() {
find . -type f -name \*.go -not -name \*_cbor_gen.go | grep -v './extern/filecoin-ffi' | grep -v './extern/test-vectors' find . -type f -name \*.go -not -name \*_cbor_gen.go | grep -v './extern/filecoin-ffi' | grep -v './extern/test-vectors'
} }
go_files | xargs -I '{}' sed -i.ifixbak -e '/import (/ { # Because -i works differently on macOS, we need to use a different sed command
:1 if [[ "$OSTYPE" == "darwin"* ]]; then
$!N go_files | xargs -I '{}' sed -i '' -e "$sed_replace" '{}'
s/\n\n/\'$'\n''/ else
/)/!b1 go_files | xargs -I '{}' sed -i -e "$sed_replace" '{}'
}' '{}' fi
find . -type f -name \*.go.ifixbak | xargs rm
go_files | xargs -I '{}' goimports -w -local "github.com/filecoin-project" '{}' go_files | xargs -I '{}' goimports -w -local "github.com/filecoin-project" '{}'
go_files | xargs -I '{}' goimports -w -local "github.com/filecoin-project/lotus" '{}' go_files | xargs -I '{}' goimports -w -local "github.com/filecoin-project/lotus" '{}'