jpsider / RestPS

Simple ReST Framework for Powershell
MIT License
114 stars 30 forks source link

Invoke-DeployRestPS not working if the module is not present in standard folders #30

Closed Tonic8 closed 4 years ago

Tonic8 commented 4 years ago

Hello

trying to test the module i usually create a folder with my test script and a subfolder with the module to test.

first line of the script is import-module c:\test1\modules\RestPS

when trying to execute the command

PS C:\> Invoke-DeployRestPS -LocalDir 'c:\RestPS'
Creating RestPS Directories.

    Directory: C:\

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       11/14/2019  10:11 AM                RestPS

    Directory: C:\RestPS

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       11/14/2019  10:11 AM                bin
d-----       11/14/2019  10:11 AM                endpoints

    Directory: C:\RestPS\endpoints

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       11/14/2019  10:11 AM                Logs
d-----       11/14/2019  10:11 AM                GET
d-----       11/14/2019  10:11 AM                POST
d-----       11/14/2019  10:11 AM                PUT
d-----       11/14/2019  10:11 AM                DELETE
Invoke-DeployRestPS: Cannot bind argument to parameter 'Path' because it is null.
At C:\test1\modules\restps\7.0.12\RestPS.psm1:428 char:9
+         Throw "Invoke-DeployRestPS: $ErrorMessage $FailedItem"
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Invoke-DeployRe...se it is null. :String) [], RuntimeException
    + FullyQualifiedErrorId : Invoke-DeployRestPS: Cannot bind argument to parameter 'Path' because it is null.

The issue is on the line of the function Invoke-DeployRestPS

$Source = (Split-Path -Path (Get-Module -ListAvailable RestPS | Sort-Object -Property Version -Descending | Select-Object -First 1).path) this work only for standard modules deployment, in certain case it could usefull to have a "portable" structure for the project (one folder with all logs, all modules needed, all script, etc) we can drop.

regards Tonic8

jpsider commented 4 years ago

Who doesn't like standards? So I think if I add a $sourcDir parameter this should resolve your issue. I can default it to what is there, but allow you do override it.

Sound good?

Tonic8 commented 4 years ago

hello :) yes who care on standard?, that's sound good for me.

jpsider commented 4 years ago

Just released version "7.0.14" to the PowerShell Gallery. Give that a shot and let me know if it works for you.