Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@ import 'package:shell_executor/shell_executor.dart';

class InnoSetupCompiler {
Future<bool> compile(InnoSetupScript script) async {
File file = await script.createFile();

ProcessResult processResult;

// First, try the default installation path
Directory innoSetupDirectory =
Directory('C:\\Program Files (x86)\\Inno Setup 6');

if (!innoSetupDirectory.existsSync()) {
throw Exception('`Inno Setup 6` was not installed.');
if (innoSetupDirectory.existsSync()) {
// Use ISCC from the default installation directory
processResult = await $(
p.join(innoSetupDirectory.path, 'ISCC.exe'),
[file.path],
);
} else {
// Fall back to PATH
try {
processResult = await $('ISCC', [file.path]);
} on ProcessException {
throw Exception(
'\'Inno Setup 6\' was not installed or ISCC is not in PATH.');
}
Comment on lines 28 to 30
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temporary file is not cleaned up when an exception is thrown. If the compiler is not found in PATH (line 28-30), the exception is thrown before file.deleteSync() is called (line 37). This will leave temporary script files on disk. Consider using a try-finally block to ensure cleanup, or moving file deletion earlier to handle all error paths.

Copilot uses AI. Check for mistakes.
}
Comment on lines 17 to 31
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling logic is incomplete. When the default installation path exists but ISCC.exe is not found or fails to execute (e.g., due to missing file), a ProcessException will be thrown but won't be caught. This will result in an uncaught exception instead of the clear error message intended for users. The try-catch should wrap both branches, or the first branch should also have explicit error handling.

Copilot uses AI. Check for mistakes.

File file = await script.createFile();

ProcessResult processResult = await $(
p.join(innoSetupDirectory.path, 'ISCC.exe'),
[file.path],
);

if (processResult.exitCode != 0) {
return false;
}
Expand Down