File tree 2 files changed +20
-13
lines changed
2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,19 @@ class FilePathExtractor {
10
10
String get filePath {
11
11
try {
12
12
final stackTraceString = _stackTraceFetcher.currentStackTrace;
13
- // ApprovalLogger.log('Stack trace: $stackTraceString');
14
- //final uriRegExp = RegExp(r'file:\/\/\/([^\s:]+)');
15
- final uriRegExp = RegExp (r'file://(/[a-zA-Z]:[^\s]*)' );
13
+
14
+ final uriRegExp = RegExp (isWindows ? _windowsPattern : _linuxMacOSPattern);
16
15
final match = uriRegExp.firstMatch (stackTraceString);
17
16
18
17
if (match != null ) {
19
- final rawPath = match.group (1 )! .replaceAll (RegExp (r':\d+:\d+\)$' ), '' );
20
- final filePath = Uri .parse ('file://$rawPath ' );
21
- return filePath.toFilePath (windows: Platform .isWindows);
18
+ if (isWindows) {
19
+ final rawPath = match.group (1 )! .replaceAll (RegExp (r':\d+:\d+\)$' ), '' );
20
+ final filePath = Uri .parse ('file://$rawPath ' );
21
+ return filePath.toFilePath (windows: isWindows);
22
+ } else {
23
+ final filePath = Uri .tryParse ('file:///${match .group (1 )!}' );
24
+ return filePath! .toFilePath ();
25
+ }
22
26
} else {
23
27
throw FileNotFoundException (
24
28
message: 'File not found in stack trace' ,
@@ -29,4 +33,10 @@ class FilePathExtractor {
29
33
rethrow ;
30
34
}
31
35
}
36
+
37
+ static bool isWindows = Platform .isWindows;
38
+
39
+ static const String _windowsPattern = r'file://(/[a-zA-Z]:[^\s]*)' ;
40
+
41
+ static const String _linuxMacOSPattern = r'file:\/\/\/([^\s:]+)' ;
32
42
}
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ part of '../../../../approval_tests.dart';
3
3
/// `MacDiffTools` contains diff tools available on macOS.
4
4
final class MacDiffTools {
5
5
static const DiffInfo visualStudioCode = DiffInfo (
6
- command:
7
- '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code' ,
6
+ command: '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code' ,
8
7
arg: '-d' ,
9
8
name: 'code' ,
10
9
);
@@ -28,23 +27,21 @@ final class WindowsDiffTools {
28
27
static const DiffInfo androidStudio = DiffInfo (
29
28
command: 'C:\\ Program Files\\ Android\\ Android Studio\\ bin\\ studio64.exe' ,
30
29
arg: 'diff' ,
31
- name: 'studio ' ,
30
+ name: 'studio64 ' ,
32
31
);
33
32
}
34
33
35
34
/// `LinuxDiffTools` contains diff tools available on Linux.
36
35
final class LinuxDiffTools {
37
- // TODO: check correct path for Visual Studio Code on Linux
38
36
static const DiffInfo visualStudioCode = DiffInfo (
39
37
command: '/snap/bin/code' ,
40
38
arg: '-d' ,
41
39
name: 'code' ,
42
40
);
43
41
44
- // TODO: check correct path for Android Studio on Linux
45
42
static const DiffInfo androidStudio = DiffInfo (
46
- command: '/snap/bin/studio' ,
43
+ command: '/snap/bin/android- studio' ,
47
44
arg: 'diff' ,
48
- name: 'studio' ,
45
+ name: 'android- studio' ,
49
46
);
50
47
}
You can’t perform that action at this time.
0 commit comments