Skip to content

Commit

Permalink
fix: Error suppression.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Jun 29, 2023
1 parent 0f6f028 commit 40d97f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/katana_cli/bin/katana.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ library katana_cli;
import 'dart:io';

// Package imports:
import 'package:katana_cli/command/doctor.dart';
import 'package:yaml/yaml.dart';

// Project imports:
import 'package:katana_cli/command/apply.dart';
import 'package:katana_cli/command/deploy.dart';
import 'package:katana_cli/command/doctor.dart';
import 'package:katana_cli/command/module.dart';
import 'package:katana_cli/command/store/store.dart';
import 'package:katana_cli/katana_cli.dart';
Expand Down
4 changes: 4 additions & 0 deletions packages/katana_cli/lib/command/doctor.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Project imports:
// ignore_for_file: avoid_print

// Dart imports:
import 'dart:io';

// Project imports:
import 'package:katana_cli/katana_cli.dart';

const _mainCommands = {
Expand Down Expand Up @@ -111,6 +113,7 @@ class DoctorCliCommand extends CliCommand {
"Install `${com.value}`",
[npm, "install", "-g", com.value],
runInShell: true,
catchError: true,
);
} else {
print("[o] `${com.key}` exists at `$path`");
Expand All @@ -131,6 +134,7 @@ class DoctorCliCommand extends CliCommand {
"Install `${com.value}`",
[dart, "pub", "global", "activate", com.value],
runInShell: true,
catchError: true,
);
} else {
print("[o] `${com.key}` exists at `$path`");
Expand Down
7 changes: 4 additions & 3 deletions packages/katana_cli/lib/src/framework.dart
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ Future<String> command(
List<String> commands, {
String? workingDirectory,
bool runInShell = true,
bool catchError = false,
}) {
// ignore: avoid_print, prefer_interpolation_to_compose_strings
print("\r\n#### " + title);
Expand All @@ -407,7 +408,7 @@ Future<String> command(
commands.sublist(1, commands.length),
runInShell: runInShell,
workingDirectory: workingDirectory ?? Directory.current.path,
).print();
).print(catchError);
}

/// Get the first file that matches [pattern] in [root].
Expand All @@ -433,7 +434,7 @@ extension _ProcessExtensions on Future<Process> {
/// Prints the contents of the command to standard output.
///
/// コマンドの内容を標準出力にプリントします。
Future<String> print() async {
Future<String> print(bool catchError) async {
final process = await this;
var res = "";
var err = false;
Expand All @@ -449,7 +450,7 @@ extension _ProcessExtensions on Future<Process> {
core.print(e);
});
await process.exitCode;
if (err) {
if (catchError && err) {
throw Exception(
"An error has occurred. Please check the log above for details.",
);
Expand Down

0 comments on commit 40d97f2

Please sign in to comment.