Skip to content

Commit d936aab

Browse files
committed
use executablesIds instead of listFiles
* _isDartExecutable is simplified as extension check is performed by executablesIds
1 parent 357ab38 commit d936aab

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/src/command/deps.dart

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ import '../utils.dart';
1616

1717
/// Returns `true` if [path] looks like a Dart entrypoint.
1818
bool _isDartExecutable(String path) {
19-
if (p.extension(path) == '.dart') {
20-
try {
21-
var unit = analyzer.parseDartFile(path, parseFunctionBodies: false);
22-
return isEntrypoint(unit);
23-
} on analyzer.AnalyzerErrorGroup {
24-
return false;
25-
}
19+
try {
20+
var unit = analyzer.parseDartFile(path, parseFunctionBodies: false);
21+
return isEntrypoint(unit);
22+
} on analyzer.AnalyzerErrorGroup {
23+
return false;
2624
}
27-
28-
return false;
2925
}
3026

3127
/// Handles the `deps` pub command.
@@ -277,10 +273,9 @@ class DepsCommand extends PubCommand {
277273
/// Lists all Dart files in the `bin` directory of the [package].
278274
///
279275
/// Returns file names without extensions.
280-
List<String> _getExecutablesFor(Package package) => package
281-
.listFiles(beneath: 'bin', recursive: false)
282-
.where(_isDartExecutable)
283-
.map(p.basenameWithoutExtension);
276+
List<String> _getExecutablesFor(Package package) => package.executableIds
277+
.where((e) => _isDartExecutable(p.absolute(package.dir, e.path)))
278+
.map((e) => p.basenameWithoutExtension(e.path));
284279

285280
/// Returns formatted string that lists [executables] for the [packageName].
286281
/// Examples:

0 commit comments

Comments
 (0)