diff options
author | John McCrae <john.mccrae@progress.com> | 2022-06-15 17:30:29 -0700 |
---|---|---|
committer | John McCrae <john.mccrae@progress.com> | 2022-06-24 11:23:33 -0700 |
commit | 326af7f58592cef4c6e997296ec50c4eccb39826 (patch) | |
tree | c26ca0042ee69b24bcc4bba804f2658b2a6e2c35 /lib | |
parent | 786715a03bfa2466800941d8edbbd5a558df8820 (diff) | |
download | chef-326af7f58592cef4c6e997296ec50c4eccb39826.tar.gz |
Refactored code to be more readable and changed a test to correct for starting out with Auto-Managed being false by default
Signed-off-by: John McCrae <john.mccrae@progress.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/windows_pagefile.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/chef/resource/windows_pagefile.rb b/lib/chef/resource/windows_pagefile.rb index 03649e28aa..ca80d5b2ab 100644 --- a/lib/chef/resource/windows_pagefile.rb +++ b/lib/chef/resource/windows_pagefile.rb @@ -148,10 +148,12 @@ class Chef def exists?(pagefile) @exists ||= begin logger.trace("Checking if #{pagefile} exists by running: Get-CimInstance Win32_PagefileSetting | Where-Object { $_.name -eq $($pagefile)} ") - cmd = "$page_file_name = '#{pagefile}';" - cmd << "$pagefile = Get-CimInstance Win32_PagefileSetting | Where-Object { $_.name -eq $($page_file_name)};" - cmd << "if ([string]::IsNullOrEmpty($pagefile)) { return $false } else { return $true }" - powershell_exec!(cmd).result + powershell_code = <<~CODE + $page_file_name = '#{pagefile}'; + $pagefile = Get-CimInstance Win32_PagefileSetting | Where-Object { $_.name -eq $($page_file_name)} + if ([string]::IsNullOrEmpty($pagefile)) { return $false } else { return $true } + CODE + powershell_exec!(powershell_code).result end end |