Skip to content

Commit

Permalink
Move non-0 exit code handling into try-block, ensuring we delete the …
Browse files Browse the repository at this point in the history
…output file in case of non-0
  • Loading branch information
mkustermann committed Nov 4, 2024
1 parent 2768587 commit 73908b5
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -573,31 +573,31 @@ ${e.message}
);

var deleteOutputIfExists = false;
if (result.exitCode != 0) {
final printWorkingDir = workingDirectory != Directory.current.uri;
final commandString = [
if (printWorkingDir) '(cd ${workingDirectory.toFilePath()};',
dartExecutable.toFilePath(),
...arguments.map((a) => a.contains(' ') ? "'$a'" : a),
if (printWorkingDir) ')',
].join(' ');
logger.severe(
'''
Building assets for package:${config.packageName} failed.
${hook.scriptName} returned with exit code: ${result.exitCode}.
To reproduce run:
$commandString
stderr:
${result.stderr}
stdout:
${result.stdout}
''',
);
deleteOutputIfExists = true;
return null;
}

try {
if (result.exitCode != 0) {
final printWorkingDir = workingDirectory != Directory.current.uri;
final commandString = [
if (printWorkingDir) '(cd ${workingDirectory.toFilePath()};',
dartExecutable.toFilePath(),
...arguments.map((a) => a.contains(' ') ? "'$a'" : a),
if (printWorkingDir) ')',
].join(' ');
logger.severe(
'''
Building assets for package:${config.packageName} failed.
${hook.scriptName} returned with exit code: ${result.exitCode}.
To reproduce run:
$commandString
stderr:
${result.stderr}
stdout:
${result.stdout}
''',
);
deleteOutputIfExists = true;
return null;
}

final output = _readHookOutputFromUri(hook, hookOutputFile);
final errors = await _validate(config, output, packageLayout, validator);
if (errors.isNotEmpty) {
Expand Down

0 comments on commit 73908b5

Please sign in to comment.