OLD | NEW |
| (Empty) |
1 | |
2 library which; | |
3 | |
4 import 'dart:async'; | |
5 import 'dart:io'; | |
6 | |
7 import 'src/candidate_paths.dart'; | |
8 import 'src/is_executable.dart'; | |
9 import 'src/which_impl.dart' as impl; | |
10 | |
11 /// Returns a future for the first [command] executable in the `PATH`. | |
12 /// | |
13 /// If [command] is not found, [orElse] is called, which defaults to throwing. | |
14 Future<String> which(String command, { orElse() }) => new Future(() => impl.whic
h( | |
15 command, | |
16 getRealCandidatePaths(command), | |
17 Platform.isWindows, | |
18 (path, isWindows) => isExecutable(path, isWindows, FileStat.stat), | |
19 orElse)); | |
20 | |
21 /// Returns the first [command] executable in the `PATH`. | |
22 /// | |
23 /// If [command] is not found, [orElse] is called, which defaults to throwing. | |
24 String whichSync(String command, { orElse() }) => impl.whichSync( | |
25 command, | |
26 getRealCandidatePaths(command), | |
27 Platform.isWindows, | |
28 (path, isWindows) => isExecutableSync(path, isWindows, FileStat.statSync), | |
29 orElse); | |
OLD | NEW |