diff --git a/lib/platform/process.dart b/lib/platform/process.dart index bc2a6b4..ec72ef0 100644 --- a/lib/platform/process.dart +++ b/lib/platform/process.dart @@ -115,11 +115,9 @@ class ProcessExecutor { try { var processData = ProcessData(); - var fileName = DateTime.now(); if (Platform.isMacOS || Platform.isLinux) { workspace = workspace ?? Directory.current.path; - var file = - File('$workspace/temp_${fileName.microsecondsSinceEpoch}.sh'); + var file = File('$workspace/$tempFileName'); processData.file = file; print('Execute Shell: ${file.path} \n ${shell.toString()}'); if (await file.exists()) { @@ -135,8 +133,7 @@ class ProcessExecutor { } } else if (Platform.isWindows) { workspace = workspace ?? Directory.current.path; - var file = - File('$workspace/temp_${fileName.microsecondsSinceEpoch}.bat'); + var file = File('$workspace/$tempFileName'); processData.file = file; print('Execute Shell: ${file.path} \n ${shell.toString()}'); if (await file.exists()) { @@ -167,7 +164,7 @@ class ProcessExecutor { ProcessResult? processResult; if (Platform.isMacOS || Platform.isLinux) { workspace = workspace ?? Directory.current.path; - var file = File('$workspace/temp.sh'); + var file = File('$workspace/$tempFileName'); print('Execute Shell: ${file.path} \n ${shell.toString()}'); file.createSync(); file.writeAsStringSync(shell.toString()); @@ -190,7 +187,7 @@ class ProcessExecutor { c.complete(processResult); } else if (Platform.isWindows) { workspace = workspace ?? Directory.current.path; - var file = File('$workspace/temp.bat'); + var file = File('$workspace/$tempFileName'); print('Execute Bat: ${file.path} \n ${shell.toString()}'); file.createSync(); file.writeAsStringSync(shell.toString()); @@ -213,6 +210,13 @@ class ProcessExecutor { return c.future; } + static String get tempFileName { + if (Platform.isMacOS || Platform.isLinux) + return 'temp_${DateTime.now().microsecondsSinceEpoch}.sh'; + else + return 'temp_${DateTime.now().microsecondsSinceEpoch}.bat'; + } + static bool getSuccess(int exitCode) { if (Platform.isMacOS || Platform.isLinux) return exitCode == 0; if (Platform.isWindows) return exitCode == 1;