This commit enhances the compiler's ability to inline PowerShell code
blocks. Previously, the compiler attempted to inline all lines ending
with brackets (`}` and `{`) using semicolons, which leads to syntax
errors. This improvement allows for more flexible PowerShell code
writing with reliable outcomes.
Key Changes:
- Update InlinePowerShell pipe to handle code blocks specifically
- Extend unit tests for the InlinePowerShell pipe
Other supporting changes:
- Refactor InlinePowerShell tests for improved scalability
- Enhance pipe unit test running with regex support
- Expand test coverage for various PowerShell syntax used in
privacy.sexy
- Update related interfaces to align with new code conventions, dropping
`I` prefix
- Optimize line merging to skip lines already ending with semicolons
- Increase timeout in E2E tests to accommodate for slower application
load caused by more processing introduced in this commit.
27 lines
742 B
TypeScript
27 lines
742 B
TypeScript
import type { Pipe } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/Pipe';
|
|
import type { IPipeFactory } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/PipeFactory';
|
|
|
|
export class PipeFactoryStub implements IPipeFactory {
|
|
private readonly pipes = new Array<Pipe>();
|
|
|
|
public get(pipeName: string): Pipe {
|
|
const result = this.pipes.find((pipe) => pipe.name === pipeName);
|
|
if (!result) {
|
|
throw new Error(`pipe not registered: "${pipeName}"`);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public withPipe(pipe: Pipe) {
|
|
this.pipes.push(pipe);
|
|
return this;
|
|
}
|
|
|
|
public withPipes(pipes: Pipe[]) {
|
|
for (const pipe of pipes) {
|
|
this.withPipe(pipe);
|
|
}
|
|
return this;
|
|
}
|
|
}
|