11import 'dart:async' ;
22import 'dart:io' ;
33
4+ import 'package:dart_dev/src/utils/start_process_and_ensure_exit.dart' ;
45import 'package:logging/logging.dart' ;
56
67import '../dart_dev_tool.dart' ;
@@ -25,14 +26,20 @@ final _log = Logger('Process');
2526/// It is also possible to run this tool directly in a dart script:
2627/// ProcessTool(exe, args).run();
2728class ProcessTool extends DevTool {
28- ProcessTool (String executable, List <String > args, {ProcessStartMode mode})
29+ ProcessTool (String executable, List <String > args,
30+ {ProcessStartMode mode, String workingDirectory})
2931 : _args = args,
3032 _executable = executable,
31- _mode = mode;
33+ _mode = mode,
34+ _workingDirectory = workingDirectory;
3235
3336 final List <String > _args;
3437 final String _executable;
3538 final ProcessStartMode _mode;
39+ final String _workingDirectory;
40+
41+ Process get process => _process;
42+ Process _process;
3643
3744 @override
3845 FutureOr <int > run ([DevToolExecutionContext context]) async {
@@ -43,8 +50,10 @@ class ProcessTool extends DevTool {
4350 commandName: context.commandName);
4451 }
4552 logSubprocessHeader (_log, '$_executable ${_args .join (' ' )}' );
46- return runProcessAndEnsureExit (
47- ProcessDeclaration (_executable, _args, mode: _mode),
53+ _process = await startProcessAndEnsureExit (
54+ ProcessDeclaration (_executable, _args,
55+ mode: _mode, workingDirectory: _workingDirectory),
4856 log: _log);
57+ return _process.exitCode;
4958 }
5059}
0 commit comments