Skip to content

Commit

Permalink
generate the powershell add_to_PATH.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
enricosada committed Jan 4, 2018
1 parent 125ac1c commit 7e3193f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 3 additions & 5 deletions integrationtests/Paket.IntegrationTests/RepoToolSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ let ``#3003 repo tool with add to PATH``() =

let wrappersPath = Path.Combine(scenarioTempPath scenario, "paket-files", "bin")

let helloCmdPath = Path.Combine(wrappersPath, "add_to_PATH.cmd")
Assert.IsTrue(File.Exists(helloCmdPath), (sprintf "file '%s' not found" helloCmdPath))

let helloBashPath = Path.Combine(wrappersPath, "add_to_PATH.sh")
Assert.IsTrue(File.Exists(helloBashPath), (sprintf "file '%s' not found" helloBashPath))
for name in ["add_to_PATH.cmd"; "add_to_PATH.sh"; "add_to_PATH.ps1"] do
let cmdPath = Path.Combine(wrappersPath, name)
Assert.IsTrue(File.Exists(cmdPath), (sprintf "file '%s' not found" cmdPath))

[<Test>]
let ``#3004 repo tool multi tfm (net)``() =
Expand Down
2 changes: 2 additions & 0 deletions src/Paket.Core/Installation/RestoreProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ let CreateToolWrapperForGroups (lockFile:LockFile) (groups:Map<GroupName,LockFil
script.Save
| RepoTools.WrapperToolGeneration.ScriptContent.ShellAddToPATH script ->
script.Save
| RepoTools.WrapperToolGeneration.ScriptContent.PowershellAddToPATH script ->
script.Save
saveScript rootPath |> ignore

let FindOrCreateReferencesFile (projectFile:ProjectFile) =
Expand Down
19 changes: 19 additions & 0 deletions src/Paket.Core/Installation/WrapperToolGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ module WrapperToolGeneration =
member self.Save (rootPath:DirectoryInfo) =
saveScript self.Render rootPath self.PartialPath

type ScriptAddToPATHPowershell = {
PartialPath : string
} with
member self.Render (_directory:DirectoryInfo) =
let cmdContent =
[ ""
"$env:PATH = $PSScriptRoot + ';' + $env:PATH"
"" ]

cmdContent |> String.concat "\r\n"

/// Save the script in '<directory>/paket-files/bin/<script>'
member self.Save (rootPath:DirectoryInfo) =
saveScript self.Render rootPath self.PartialPath

type ScriptContentWindows = {
PartialPath : string
RelativeToolPath : string
Expand Down Expand Up @@ -171,6 +186,7 @@ module WrapperToolGeneration =
| Shell of ScriptContentShell
| WindowsAddToPATH of ScriptAddToPATHWindows
| ShellAddToPATH of ScriptAddToPATHShell
| PowershellAddToPATH of ScriptAddToPATHPowershell

type RepoToolInNupkg =
{ FullPath: string
Expand Down Expand Up @@ -329,6 +345,9 @@ module WrapperToolGeneration =
[ { ScriptAddToPATHWindows.PartialPath = scriptPath </> "add_to_PATH.cmd" }
|> ScriptContent.WindowsAddToPATH

{ ScriptAddToPATHPowershell.PartialPath = scriptPath </> "add_to_PATH.ps1" }
|> ScriptContent.PowershellAddToPATH

{ ScriptAddToPATHShell.PartialPath = scriptPath </> "add_to_PATH.sh" }
|> ScriptContent.ShellAddToPATH ] )

Expand Down

0 comments on commit 7e3193f

Please sign in to comment.