Skip to content

Conversation

@sophieyfang
Copy link
Contributor

@sophieyfang sophieyfang commented Aug 3, 2021

Test when there is no config file

Screen Shot 2021-08-03 at 4 43 48 PM

Test when there is config file

Screen Shot 2021-08-03 at 4 45 01 PM

ToDOO

@sophieyfang sophieyfang marked this pull request as ready for review August 6, 2021 20:00
@sophieyfang
Copy link
Contributor Author

Sync'ed with @qingling128. We need to make consistency among Linux and Windows. Thus default-config.yaml isn't necessary to have in this case. I will remove it in next commit

Copy link
Contributor

@qingling128 qingling128 left a comment

Choose a reason for hiding this comment

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

LGTM

@sophieyfang sophieyfang changed the title Keep config.yaml file if existing and have a copy of original default in the disk Keep config.yaml file if existing Aug 10, 2021
@sophieyfang sophieyfang merged commit 3e4b243 into master Aug 10, 2021
@sophieyfang sophieyfang deleted the sophieyfang-windows-confiig branch August 10, 2021 14:09
Copy link
Contributor

@igorpeshansky igorpeshansky left a comment

Choose a reason for hiding this comment

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

Had some unsent comments on older commits… If you find you want to address them, we can do that in a follow-up PR.

$InstallDir = [regex]::Replace($InstallDir,'^<([^>]+)>',$envFromMatch)

$configFilePath = "$InstallDir\config\config.yaml"
if (-not(Test-Path -Path $configFilePath -PathType Leaf)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a space after -not.

Write-Host "The file [$configFilePath] has been created."
}
catch {
throw $_.Exception.Message
Copy link
Contributor

Choose a reason for hiding this comment

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

Why catch and rethrow, when you can just let it propagate naturally?

if (-not(Test-Path -Path $configFilePath -PathType Leaf)) {
try {
Copy-Item -Path "$InstallDir\config\default-config.yaml" -Destination $configFilePath
Write-Host "The file [$configFilePath] has been created."
Copy link
Contributor

Choose a reason for hiding this comment

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

How about something like Copied default config into [$configFilePath].?

}
}
else {
Write-Host "Keep [$configFilePath] as-is because a file with that name already exists."
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not worth adding this message…

$InstallDir = [regex]::Replace($InstallDir,'^<([^>]+)>',$envFromMatch)

$configFilePath = "$InstallDir\config\config.yaml"
if (-not(Test-Path -Path $configFilePath -PathType Leaf)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Careful — this will run both when $Action is "install" and when $Action is "uninstall". You probably want to run it only in the "install" case.

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.

4 participants