diff --git a/test/samy.ps1 b/test/samy.ps1 index de2a5e3..b51d67a 100644 --- a/test/samy.ps1 +++ b/test/samy.ps1 @@ -17,7 +17,7 @@ - The iwr | iex glue at the bottom so remote calls still work. All heavy logic lives in the Samy.*.ps1 subsystem files that are dot-sourced or - loaded from your Git repo. + loaded from your Git repo, now under a "module" subfolder. #> #region Safely bypass Restricted Execution Policy @@ -77,9 +77,12 @@ function Import-SamyModule { Loads a SAMY subsystem script from local disk or from the Git repo. .DESCRIPTION - 1. If running from a saved script (PSCommandPath) and the file exists next to it, - dot-sources that local file (dev mode). - 2. Otherwise, downloads the module from $Script:SamyRepoBase / $Script:SamyBranch + Modules are now expected under a "module" subfolder. + + 1. If running from a saved script (PSCommandPath) and the file exists under + .\module\, dot-sources that local file (dev mode). + 2. Otherwise, downloads the module from: + $Script:SamyRepoBase / $Script:SamyBranch / module / ?raw=1 and Invoke-Expression on its content (remote iwr|iex mode). .PARAMETER Name @@ -90,17 +93,19 @@ function Import-SamyModule { [Parameter(Mandatory)][string]$Name ) - # 1) Local dev mode: script saved to disk, use PSScriptRoot + # 1) Local dev mode: script saved to disk, use .\module\ if ($PSCommandPath) { - $localPath = Join-Path -Path $PSScriptRoot -ChildPath $Name + $moduleRoot = Join-Path -Path $PSScriptRoot -ChildPath 'module' + $localPath = Join-Path -Path $moduleRoot -ChildPath $Name + if (Test-Path $localPath) { . $localPath return } } - # 2) Remote mode (iwr | iex): pull module from repo - $url = "$Script:SamyRepoBase/$Script:SamyBranch/$Name?raw=1" + # 2) Remote mode (iwr | iex): pull module from repo/module + $url = "$Script:SamyRepoBase/$Script:SamyBranch/module/$Name?raw=1" try { $resp = Invoke-WebRequest -Uri $url -UseBasicParsing -ErrorAction Stop @@ -300,8 +305,6 @@ function Invoke-ScriptAutomationMonkey { } -ArgumentList $url, $edgePath | Out-Null # Start HTTP listener loop (implemented in Samy.Http.ps1) - # Expected exported function: - # Start-SamyHttpServer -Port Start-SamyHttpServer -Port $port return }