Update test/samy.ps1
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
- The iwr | iex glue at the bottom so remote calls still work.
|
- 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
|
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
|
#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.
|
Loads a SAMY subsystem script from local disk or from the Git repo.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
1. If running from a saved script (PSCommandPath) and the file exists next to it,
|
Modules are now expected under a "module" subfolder.
|
||||||
dot-sources that local file (dev mode).
|
|
||||||
2. Otherwise, downloads the module from $Script:SamyRepoBase / $Script:SamyBranch
|
1. If running from a saved script (PSCommandPath) and the file exists under
|
||||||
|
.\module\<Name>, dot-sources that local file (dev mode).
|
||||||
|
2. Otherwise, downloads the module from:
|
||||||
|
$Script:SamyRepoBase / $Script:SamyBranch / module / <Name>?raw=1
|
||||||
and Invoke-Expression on its content (remote iwr|iex mode).
|
and Invoke-Expression on its content (remote iwr|iex mode).
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
@@ -90,17 +93,19 @@ function Import-SamyModule {
|
|||||||
[Parameter(Mandatory)][string]$Name
|
[Parameter(Mandatory)][string]$Name
|
||||||
)
|
)
|
||||||
|
|
||||||
# 1) Local dev mode: script saved to disk, use PSScriptRoot
|
# 1) Local dev mode: script saved to disk, use .\module\<Name>
|
||||||
if ($PSCommandPath) {
|
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) {
|
if (Test-Path $localPath) {
|
||||||
. $localPath
|
. $localPath
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 2) Remote mode (iwr | iex): pull module from repo
|
# 2) Remote mode (iwr | iex): pull module from repo/module
|
||||||
$url = "$Script:SamyRepoBase/$Script:SamyBranch/$Name?raw=1"
|
$url = "$Script:SamyRepoBase/$Script:SamyBranch/module/$Name?raw=1"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$resp = Invoke-WebRequest -Uri $url -UseBasicParsing -ErrorAction Stop
|
$resp = Invoke-WebRequest -Uri $url -UseBasicParsing -ErrorAction Stop
|
||||||
@@ -300,8 +305,6 @@ function Invoke-ScriptAutomationMonkey {
|
|||||||
} -ArgumentList $url, $edgePath | Out-Null
|
} -ArgumentList $url, $edgePath | Out-Null
|
||||||
|
|
||||||
# Start HTTP listener loop (implemented in Samy.Http.ps1)
|
# Start HTTP listener loop (implemented in Samy.Http.ps1)
|
||||||
# Expected exported function:
|
|
||||||
# Start-SamyHttpServer -Port <int>
|
|
||||||
Start-SamyHttpServer -Port $port
|
Start-SamyHttpServer -Port $port
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user