You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 16, 2023. It is now read-only.
feat: implement --sdk-path CLI option to use when running as compiled executable (#430)
* feat: implement --sdk-path CLI option to use when running as Windows EXE
* docs: add link to official docs
* fix: add "sdk-path" option to "CheckUnusedL10nCommand"
* test: add tests for BaseCommand.validateSdkPath and detectSdkPath
* chore: fix analyzer issue
* fix: use sdk-path in check_unused_l10n.dart
* refactor: remove code duplication
* fix: remove unneeded override
* refactor: address review comment
* test: add test for 'findSdkPath`
* test: add a test case for "detectSdkPath"
* test: fix existing and add new test
* docs: don't mention Windows platform
* docs: fix changelog entry
* refactor: convert "sdkPath" to named argument
* docs: don't mention Windows in CHANGELOG.md
--sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.
166
167
--exclude=<{/**.g.dart,/**.template.dart}> File paths in Glob syntax to be exclude.
@@ -26,12 +27,15 @@ abstract class BaseCommand extends Command<void> {
26
27
@override
27
28
Future<void> run() =>_verifyThenRunCommand();
28
29
29
-
@protected
30
-
voidvalidateCommand();
31
-
32
30
@protected
33
31
Future<void> runCommand();
34
32
33
+
voidvalidateCommand() {
34
+
validateRootFolderExist();
35
+
validateSdkPath();
36
+
validateTargetDirectories();
37
+
}
38
+
35
39
voidusesRootFolderOption() {
36
40
argParser
37
41
..addSeparator('')
@@ -43,6 +47,15 @@ abstract class BaseCommand extends Command<void> {
43
47
);
44
48
}
45
49
50
+
voidusesSdkPathOption() {
51
+
argParser.addOption(
52
+
FlagNames.sdkPath,
53
+
help:
54
+
'Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.',
55
+
valueHelp:'directory-path',
56
+
);
57
+
}
58
+
46
59
voidusesExcludeOption() {
47
60
argParser.addOption(
48
61
FlagNames.exclude,
@@ -62,6 +75,16 @@ abstract class BaseCommand extends Command<void> {
62
75
}
63
76
}
64
77
78
+
voidvalidateSdkPath() {
79
+
final sdkPath = argResults[FlagNames.sdkPath] asString?;
80
+
if (sdkPath !=null&&!Directory(sdkPath).existsSync()) {
81
+
final _exceptionMessage =
82
+
'Dart SDK path $sdkPath does not exist or not a directory.';
83
+
84
+
throwInvalidArgumentException(_exceptionMessage);
85
+
}
86
+
}
87
+
65
88
voidvalidateTargetDirectories() {
66
89
if (argResults.rest.isEmpty) {
67
90
const _exceptionMessage =
@@ -83,6 +106,20 @@ abstract class BaseCommand extends Command<void> {
0 commit comments