mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-29 04:55:12 +02:00
fix: scan piped foreach grouping blocks
This commit is contained in:
@@ -428,6 +428,7 @@ function invokesContainerResult(prefix, options = {}) {
|
||||
const pipelineStart = clause.lastIndexOf('|');
|
||||
const pipelineCommand = clause.slice(pipelineStart + 1).trim();
|
||||
const isForeachLoopHeader = Boolean(options.groupingExpression) &&
|
||||
pipelineStart === -1 &&
|
||||
/^foreach$/i.test(pipelineCommand);
|
||||
return /(?:^|\s)(?:&|\.)\s*$/.test(clause) ||
|
||||
/\.\s*(?:foreach|where)\s*$/i.test(clause) ||
|
||||
|
||||
@@ -488,6 +488,9 @@ test('distinguishes foreach statements from the pipeline alias', () => {
|
||||
expectRules('1 | foreach { Remove-Item -Force C:/tmp/demo }', [
|
||||
RULES.REMOVE_FORCE,
|
||||
]);
|
||||
expectRules('1 | foreach ({ Remove-Item -Force C:/tmp/demo })', [
|
||||
RULES.REMOVE_FORCE,
|
||||
]);
|
||||
});
|
||||
|
||||
test('classifies invoked static script-block variables but leaves assignments inert', () => {
|
||||
|
||||
Reference in New Issue
Block a user