New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require rule sources from current working directory to be explicitly included #760
Comments
@BernieWhite Considering the new behaviour from #610, this would mean that sources loaded from I would still expect module sources to be preferred by default: Import-Module .\out\modules\PSRule
Import-Module .\tests\PSRule.Tests\TestModule\
cd .\tests\PSRule.Tests\TestModule\
Get-PSRuleHelp
Name ModuleName Synopsis
---- ---------- --------
M1.Rule1 TestModule Synopsis en-AU.
M1.Rule2 TestModule This is the default
M1.YamlTestName TestModule This is an example YAML rule. But if we are only explicit with Get-PSRuleHelp -Path $PWD
Name ModuleName Synopsis
---- ---------- --------
M1.Rule1 This is the default
M1.Rule2 This is the default
M1.YamlTestName A YAML rule for testing If we also include Get-PSRuleHelp -Path $PWD -Module TestModule
WARNING: A rule with the same name 'M1.Rule1' already exists.
WARNING: A rule with the same name 'M1.Rule2' already exists.
WARNING: A rule with the same name 'M1.YamlTestName' already exists.
Name ModuleName Synopsis
---- ---------- --------
M1.Rule1 TestModule Synopsis en-AU.
M1.Rule2 TestModule This is the default
M1.YamlTestName TestModule This is an example YAML rule. Is that correct? |
@ArmaanMcleod We still want the behaviour from #610 to be true. More specifically if you run any command such as i.e. if you
The current behaviour is complex.
The new behaviour should be, don't include
In terms of preferring modules, we should use the same behaviour that if the source is already loaded from a module which is done first then is should not be loaded again as a loose/ standalone source. |
In v1 when calling PSRule cmdlets without
-Path
and-Module
parameters, rule sources from the current working directory$PWD
are automatically included.Including
$PWD
is problematic in some scenarios such as build pipelines when rule sources may be stored in temporary paths such asout/
.Now that the default recommend path
.ps-rule/
for standalone rules is automatically included also including$PWD
is not required.From v2 onwards,
$PWD
should not be included unless-Path .
or-Path $PWD
is explicitly specified.The text was updated successfully, but these errors were encountered: