summaryrefslogtreecommitdiff
path: root/distro
diff options
context:
space:
mode:
authorKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-05-06 18:13:40 -0400
committerKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-06-09 14:20:35 -0400
commitd63b9d2e0cabe87cf6db6657301cf525a4fea876 (patch)
tree21952742197dfbdb54d74722cb2b248bba092cb0 /distro
parent1b79704f4700e8ebbcbb04a9a6636b0b2e780920 (diff)
downloadchef-d63b9d2e0cabe87cf6db6657301cf525a4fea876.tar.gz
Change paths to correctly call embedded ruby.
Diffstat (limited to 'distro')
-rw-r--r--distro/powershell/chef/chef.psm119
1 files changed, 16 insertions, 3 deletions
diff --git a/distro/powershell/chef/chef.psm1 b/distro/powershell/chef/chef.psm1
index 670667b7a2..56b42af78c 100644
--- a/distro/powershell/chef/chef.psm1
+++ b/distro/powershell/chef/chef.psm1
@@ -1,4 +1,12 @@
-function Run-Command($command, $argList) {
+function Get-ScriptDirectory {
+ if (!$PSScriptRoot) {
+ $Invocation = (Get-Variable MyInvocation -Scope 1).Value
+ $PSScriptRoot = Split-Path $Invocation.MyCommand.Path
+ }
+ $PSScriptRoot
+}
+
+function Run-Command($command, $argList) {
# Take each input string, escape any \ ' or " character in it and then surround it with "s.
# This is to defeat the second-level parsing performed by the MSVCRT argument parser used
# by ruby which only understands \ ' and ".
@@ -10,8 +18,13 @@
# that needs substituting - it's a capture group that's interpreted by the regex engine.
# \ in the replacement pattern does not need to be escaped - it is literally substituted.
$transformed = $argList | foreach { '"' + ( $_ -replace "([\\'""])",'\$1' ) + '"' }
+
#& "echoargs.exe" $transformed
- & "ruby.exe" $command $transformed
+ # Use the correct embedded ruby path. We'll be deployed at a path that looks like
+ # [C:\opscode or some other prefix]\chef\modules\chef
+ $ruby = Join-Path (Get-ScriptDirectory) "..\..\embedded\bin\ruby.exe"
+ $commandPath = Join-Path (Get-ScriptDirectory) "..\..\bin\$command"
+ & $ruby $commandPath $transformed
}
@@ -44,4 +57,4 @@ function knife {
}
Export-ModuleMember -function chef-*
-Export-ModuleMember -function knife \ No newline at end of file
+Export-ModuleMember -function knife