src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

local-mod-replace.sh (791B)


      1 #1/usr/bin/env bash
      2 
      3 PROJECT_DIR=""
      4 SMITHY_SOURCE_DIR=$(cd `dirname $0` && pwd)
      5 
      6 usage() {
      7   echo "Usage: $0 [-s SMITHY_SOURCE_DIR] [-d PROJECT_DIR]" 1>&2
      8   exit 1
      9 }
     10 
     11 while getopts "hs:d:" options; do
     12   case "${options}" in
     13   s)
     14     SMITHY_SOURCE_DIR=${OPTARG}
     15     if [ "$SMITHY_SOURCE_DIR" == "" ]; then
     16       echo "path to smithy-go source directory is required" || exit
     17       usage
     18     fi
     19     ;;
     20   d)
     21     PROJECT_DIR=${OPTARG}
     22     ;;
     23   h)
     24     usage
     25     ;;
     26   *)
     27     usage
     28     ;;
     29   esac
     30 done
     31 
     32 if [ "$PROJECT_DIR" != "" ]; then
     33   cd $PROJECT_DIR || exit
     34 fi
     35 
     36 go mod graph | awk '{print $1}' | cut -d '@' -f 1 | sort | uniq | grep "github.com/aws/smithy-go" | while read x; do
     37   repPath=${x/github.com\/aws\/smithy-go/${SMITHY_SOURCE_DIR}}
     38   echo -replace $x=$repPath
     39 done | xargs go mod edit