RamblingCookieMonster / BuildHelpers

Helper functions for PowerShell CI/CD scenarios
MIT License
214 stars 47 forks source link

better project name detection when CI doesn't use sensible name as root dir #114

Closed FISHMANPET closed 5 years ago

FISHMANPET commented 5 years ago

fixes #107 In Azure Pipelines and possibly other CIs, the root directory isn't related to the project name, so existing detection methods that depend on the root directory name matching other files or folders in the repository don't work.

This adds two more cases. First, if we find any *.psd1s in the root of the folder, that'll be the project name. If that fails, we'll fallback to Git to get the origin URL, split it on slashes, grab the last token (which should be just the name) and then also strip out ".git" because sometimes that's part of the origin URL.

I replicated the seemingly odd behavior that if there are multiple found PSDs it will return an array, which eventually gets joined with a space, so if there's project1.psd1 and project2.psd1 found the project name will be project1 project2.

RamblingCookieMonster commented 5 years ago

Works for me, thanks!