-
-
Notifications
You must be signed in to change notification settings - Fork 209
Open
Description
新年快乐!
class InnoSetupCompiler {
Future<bool> compile(InnoSetupScript script) async {
Directory innoSetupDirectory =
Directory('C:\\Program Files (x86)\\Inno Setup 6');
if (!innoSetupDirectory.existsSync()) {
throw Exception('`Inno Setup 6` was not installed.');
}
inno setup也可以通过scoop安装的
https://github.com/ScoopInstaller/Extras/blob/master/bucket/inno-setup.json
此时安装目录不在C:\\Program Files (x86)\\Inno Setup 6,但iscc.exe仍然放进了$PATH环境变量中,可以在shell中直接执行
应该可以模仿flutter SDK调用git的方式
https://github.com/flutter/flutter/blob/f5825a22a47969ce9fec303dbefee035eadb1acc/packages/flutter_tools/lib/src/globals.dart#L111
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/git.dart
不过确实不太懂dart语法,我猜改完的代码应该是这样……?
import 'dart:io';
import 'package:flutter_app_packager/src/makers/exe/inno_setup/inno_setup_script.dart';
import 'package:path/path.dart' as p;
import 'package:shell_executor/shell_executor.dart';
class InnoSetupCompiler {
Future<bool> compile(InnoSetupScript script) async {
Directory innoSetupDirectory =
Directory('C:\\Program Files (x86)\\Inno Setup 6');
// ✅ CHANGED: decide how to invoke ISCC:
// - Prefer the original hard-coded location if it exists.
// - Otherwise fall back to just "iscc" and let the OS resolve it from PATH.
final String isccExecutable = File(p.join(innoSetupDirectory.path, 'ISCC.exe'))
.existsSync()
? p.join(innoSetupDirectory.path, 'ISCC.exe')
: 'iscc';
// ✅ CHANGED: only throw when BOTH the hard-coded path is unavailable
// and we also cannot find "iscc" on PATH (i.e., fallback would fail).
if (isccExecutable == 'iscc') {
final check = await Process.run(
'iscc',
['/??'],
runInShell: true,
);
if (check.exitCode != 0) {
throw Exception(
'`Inno Setup 6` was not installed or `iscc` was not found in PATH.',
);
}
}
File file = await script.createFile();
// ✅ CHANGED: run resolved executable (absolute path OR "iscc" via PATH)
ProcessResult processResult = await $(
isccExecutable,
[file.path],
);
if (processResult.exitCode != 0) {
return false;
}
file.deleteSync(recursive: true);
return true;
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels