Skip to content

Commit

Permalink
. r command where for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yelmuratoff committed May 18, 2024
1 parent 0d98200 commit 78d7431
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/src/core/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ final class ApprovalUtils {
final int green = int.parse(hex.substring(2, 4), radix: 16);
final int blue = int.parse(hex.substring(4, 6), radix: 16);

final AnsiPen pen = AnsiPen()
..rgb(r: red / 255, g: green / 255, b: blue / 255);
final AnsiPen pen = AnsiPen()..rgb(r: red / 255, g: green / 255, b: blue / 255);
return pen;
}

Expand Down Expand Up @@ -50,4 +49,12 @@ final class ApprovalUtils {
rethrow;
}
}

static String get commandWhere {
if (Platform.isWindows) {
return 'where';
} else {
return 'which';
}
}
}
2 changes: 2 additions & 0 deletions lib/src/reporters/diff_tool/diff_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ part of '../../../../approval_tests.dart';
class DiffInfo {
final String command;
final String arg;
final String name;

const DiffInfo({
required this.command,
required this.arg,
required this.name,
});
}
2 changes: 1 addition & 1 deletion lib/src/reporters/diff_tool/diff_tool_reporter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DiffReporter implements Reporter {
rethrow;
}
if (e is ProcessException) {
final ProcessResult result = await Process.run('which', ['code']);
final ProcessResult result = await Process.run(ApprovalUtils.commandWhere, [diffInfo.command]);
ApprovalLogger.exception(
'Error during comparison via ${ide.name}. Please try check path of IDE. \n Current path: ${diffInfo.command} with arg: "${diffInfo.arg}" \n Path to IDE (${Platform.operatingSystem}): ${result.stdout} \n Please, add path to customDiffInfo.',
stackTrace: st,
Expand Down
6 changes: 6 additions & 0 deletions lib/src/reporters/diff_tool/diff_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ final class MacDiffTools {
static const DiffInfo visualStudioCode = DiffInfo(
command: '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code',
arg: '-d',
name: 'code',
);

static const DiffInfo androidStudio = DiffInfo(
command: '/Applications/Android Studio.app/Contents/MacOS/studio',
arg: 'diff',
name: 'studio',
);
}

Expand All @@ -18,12 +20,14 @@ final class WindowsDiffTools {
static const DiffInfo visualStudioCode = DiffInfo(
command: 'C:\\Program Files\\Microsoft VS Code\\Code.exe',
arg: '-d',
name: 'code',
);

// TODO: check correct path for Android Studio on Windows
static const DiffInfo androidStudio = DiffInfo(
command: 'C:\\Program Files\\Android\\Android Studio\\bin\\studio64.exe',
arg: 'diff',
name: 'studio',
);
}

Expand All @@ -33,11 +37,13 @@ final class LinuxDiffTools {
static const DiffInfo visualStudioCode = DiffInfo(
command: '/snap/bin/code',
arg: '-d',
name: 'code',
);

// TODO: check correct path for Android Studio on Linux
static const DiffInfo androidStudio = DiffInfo(
command: '/snap/bin/studio',
arg: 'diff',
name: 'studio',
);
}

0 comments on commit 78d7431

Please sign in to comment.