OLD | NEW |
1 library pub.validator.executable; | 1 library pub.validator.executable; |
2 import 'dart:async'; | 2 import 'dart:async'; |
3 import 'package:path/path.dart' as p; | 3 import 'package:path/path.dart' as p; |
4 import '../entrypoint.dart'; | 4 import '../entrypoint.dart'; |
5 import '../validator.dart'; | 5 import '../validator.dart'; |
6 class ExecutableValidator extends Validator { | 6 class ExecutableValidator extends Validator { |
7 ExecutableValidator(Entrypoint entrypoint) : super(entrypoint); | 7 ExecutableValidator(Entrypoint entrypoint) : super(entrypoint); |
8 Future validate() { | 8 Future validate() { |
9 final completer0 = new Completer(); | 9 final completer0 = new Completer(); |
10 scheduleMicrotask(() { | 10 scheduleMicrotask(() { |
11 try { | 11 try { |
12 var binFiles = entrypoint.root.listFiles( | 12 var binFiles = entrypoint.root.listFiles( |
13 beneath: "bin", | 13 beneath: "bin", |
14 recursive: false).map( | 14 recursive: false).map(((path) => entrypoint.root.relative(path))).to
List(); |
15 ((path) => p.relative(path, from: entrypoint.root.dir))).toList(
); | |
16 entrypoint.root.pubspec.executables.forEach(((executable, script) { | 15 entrypoint.root.pubspec.executables.forEach(((executable, script) { |
17 var scriptPath = p.join("bin", "$script.dart"); | 16 var scriptPath = p.join("bin", "$script.dart"); |
18 if (binFiles.contains(scriptPath)) return; | 17 if (binFiles.contains(scriptPath)) return; |
19 warnings.add( | 18 warnings.add( |
20 'Your pubspec.yaml lists an executable "$executable" that ' | 19 'Your pubspec.yaml lists an executable "$executable" that ' |
21 'points to a script "$scriptPath" that does not exist.'); | 20 'points to a script "$scriptPath" that does not exist.'); |
22 })); | 21 })); |
23 completer0.complete(null); | 22 completer0.complete(null); |
24 } catch (e0) { | 23 } catch (e0) { |
25 completer0.completeError(e0); | 24 completer0.completeError(e0); |
26 } | 25 } |
27 }); | 26 }); |
28 return completer0.future; | 27 return completer0.future; |
29 } | 28 } |
30 } | 29 } |
OLD | NEW |