Skip to content

Commit

Permalink
feat: make update-sln diff aware (#15)
Browse files Browse the repository at this point in the history
* calculate the diff between current directory structure and sln representation
  - remove items from the sln that no longer exist on disk
  - add items to the sln that exist on disk and do not appear in the sln
  • Loading branch information
dmccaffery authored May 7, 2019
1 parent 97828d5 commit 4baa9f7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/scripts/update-sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/usr/bin/env bash

rm -rf *.sln 1>/dev/null
dotnet new sln
find . -name *.csproj | xargs dotnet sln add
__contains() { for item in "${@:2}"; do [[ "$item" == "$1" ]] && return 0; done; return 1; }

for SLN in *.sln; do
EXISTING=($(dotnet sln "$SLN" list))
EXISTING=("${EXISTING[@]:2}")
DISCOVERED=($(find * -name '*.csproj' ! -path '*/bin/*' ! -path '*/obj/*' ! -path '*/shared/*' ))

for existing in "${EXISTING[@]}"; do
__contains $existing "${DISCOVERED[@]}" || dotnet sln "$SLN" remove "$existing"
done

for discovered in "${DISCOVERED[@]}"; do
__contains $discovered "${EXISTING[@]}" || dotnet sln "$SLN" add "$discovered"
done
done

0 comments on commit 4baa9f7

Please sign in to comment.