Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-165: Fixing NuGet publishing for repositories without an sln file #30

Merged
merged 6 commits into from
Aug 5, 2022

Conversation

Piedone
Copy link
Member

@Piedone Piedone commented Aug 5, 2022

@@ -16,7 +16,16 @@

param([array] $Arguments)

foreach ($project in (dotnet sln list | Select-Object -Skip 2 | Get-Item))
if (!(Get-ChildItem *.sln))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stick with -not for neqation instead of the undocumented exclamation mark. However if you swap the if-else then you don't need any negation in the first place and save an extra pair of parens too.

Also Test-Path would be more expressive here than Get-ChildItem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the first one something the analyzers should catch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it should. I've opened an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

Comment on lines 19 to 26
if (!(Get-ChildItem *.sln))
{
$projects = Get-ChildItem *.csproj
}
else
{
$projects = (dotnet sln list | Select-Object -Skip 2 | Get-Item)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PowerShell statements return a value too. This is so beautiful it brings tears to my eyes.
So you can do

$projects = if ( ... )
{
}
else
{
}

instead of assigning to the variable in each branch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂 or 😢 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥲

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like poor man's ternary operator to me! Fortunately, PS 7 has actual ternary operators. I briefly contemplated keeping Windows PowerShell compatibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more like a rich man's ternary operator because you can have multiple expressions in each arm so it's more powerful than a ternary. But yes, please use ternary then. This repo is already not compatible with Windows PowerShell.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, and it's lavish with all the characters. Almost like showing off! :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D

@sarahelsaig sarahelsaig merged commit dcb02df into dev Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants