Fix handling special chars in script paths
This commit improves the handling of paths with spaces or special characters during script execution in the desktop application. Key improvements: - Paths are now quoted for macOS/Linux, addressing issues with whitespace or single quotes. - Windows paths are enclosed in double quotes to handle special characters. Other supporting changes: - Add more documentation for terminal execution commands. - Refactor terminal script file execution into a dedicated file for improved separation of concerns. - Refactor naming of `RuntimeEnvironment` to align with naming conventions (no interface with I prefix) and for clarity. - Refactor `TemporaryFileCodeRunner` to simplify it by removing the `os` parameter and handling OS-specific logic within the filename generator instead. - Refactor `fileName` to `filename` for consistency.
This commit is contained in:
@@ -4,9 +4,9 @@ import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
export class CommandOpsStub
|
||||
extends StubWithObservableMethodCalls<CommandOps>
|
||||
implements CommandOps {
|
||||
public execute(command: string): Promise<void> {
|
||||
public exec(command: string): Promise<void> {
|
||||
this.registerMethodCall({
|
||||
methodName: 'execute',
|
||||
methodName: 'exec',
|
||||
args: [command],
|
||||
});
|
||||
return Promise.resolve();
|
||||
|
||||
14
tests/unit/shared/Stubs/FilenameGeneratorStub.ts
Normal file
14
tests/unit/shared/Stubs/FilenameGeneratorStub.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { FilenameGenerator } from '@/infrastructure/CodeRunner/Filename/FilenameGenerator';
|
||||
|
||||
export class FilenameGeneratorStub implements FilenameGenerator {
|
||||
private filename = `[${FilenameGeneratorStub.name}]file-name-stub`;
|
||||
|
||||
public generateFilename(): string {
|
||||
return this.filename;
|
||||
}
|
||||
|
||||
public withFilename(filename: string): this {
|
||||
this.filename = filename;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IRuntimeEnvironment } from '@/infrastructure/RuntimeEnvironment/IRuntimeEnvironment';
|
||||
import { RuntimeEnvironment } from '@/infrastructure/RuntimeEnvironment/RuntimeEnvironment';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
|
||||
export class RuntimeEnvironmentStub implements IRuntimeEnvironment {
|
||||
export class RuntimeEnvironmentStub implements RuntimeEnvironment {
|
||||
public isNonProduction = true;
|
||||
|
||||
public isDesktop = true;
|
||||
|
||||
14
tests/unit/shared/Stubs/ScriptFileExecutorStub.ts
Normal file
14
tests/unit/shared/Stubs/ScriptFileExecutorStub.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ScriptFileExecutor } from '@/infrastructure/CodeRunner/Execution/ScriptFileExecutor';
|
||||
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
|
||||
export class ScriptFileExecutorStub
|
||||
extends StubWithObservableMethodCalls<ScriptFileExecutor>
|
||||
implements ScriptFileExecutor {
|
||||
public executeScriptFile(filePath: string): Promise<void> {
|
||||
this.registerMethodCall({
|
||||
methodName: 'executeScriptFile',
|
||||
args: [filePath],
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user