This repository was archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 272
feat: implement --sdk-path
CLI option to use when running as compiled executable
#430
Merged
incendial
merged 16 commits into
dart-code-checker:master
from
roman-petrov:sdk-path-option
Oct 25, 2021
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
087dcbe
feat: implement --sdk-path CLI option to use when running as Windows EXE
6bed958
docs: add link to official docs
8b8d65e
fix: add "sdk-path" option to "CheckUnusedL10nCommand"
fe2f203
test: add tests for BaseCommand.validateSdkPath and detectSdkPath
ee1ccc8
chore: fix analyzer issue
cbd5612
fix: use sdk-path in check_unused_l10n.dart
3a14c99
refactor: remove code duplication
597bc7f
fix: remove unneeded override
860eedb
refactor: address review comment
fa8b39b
test: add test for 'findSdkPath`
3798b1b
test: add a test case for "detectSdkPath"
dbe9db4
test: fix existing and add new test
8b3c45e
docs: don't mention Windows platform
f553a99
docs: fix changelog entry
b6dde60
refactor: convert "sdkPath" to named argument
9edcfbc
docs: don't mention Windows in CHANGELOG.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:path/path.dart'; | ||
|
||
String? detectSdkPath( | ||
String platformExecutable, | ||
Map<String, String> platformEnvironment, { | ||
required bool platformIsWindows, | ||
}) { | ||
String? sdkPath; | ||
// When running as compiled executable (built with `dart compile exe`) we must | ||
// pass Dart SDK path when we create analysis context. So we try to detect Dart SDK path | ||
// from system %PATH% environment variable. | ||
// | ||
// See | ||
// https://github.com/dart-code-checker/dart-code-metrics/issues/385 | ||
// https://github.com/dart-code-checker/dart-code-metrics/pull/430 | ||
const dartExeFileName = 'dart.exe'; | ||
|
||
if (platformIsWindows && | ||
!platformExecutable.toLowerCase().endsWith(dartExeFileName)) { | ||
final paths = platformEnvironment['PATH']?.split(';') ?? []; | ||
final dartExePath = paths.firstWhere( | ||
(pathEntry) => File(join(pathEntry, dartExeFileName)).existsSync(), | ||
orElse: () => '', | ||
); | ||
if (dartExePath.isNotEmpty) { | ||
// dart.exe usually is located in %SDK_PATH%\bin directory so let's use parent directory name. | ||
sdkPath = dirname(dartExePath); | ||
} | ||
} | ||
|
||
return sdkPath; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.