diff --git a/packages/process_run/analysis_options.yaml b/packages/process_run/analysis_options.yaml index 918853f..ec5c087 100644 --- a/packages/process_run/analysis_options.yaml +++ b/packages/process_run/analysis_options.yaml @@ -23,21 +23,32 @@ analyzer: linter: rules: - - public_member_api_docs - always_declare_return_types - avoid_dynamic_calls + - avoid_print - avoid_slow_async_io - cancel_subscriptions + - deprecated_member_use_from_same_package - directives_ordering + - implicit_reopen + - invalid_case_patterns + - invalid_runtime_check_with_js_interop_types + - iterable_contains_unrelated_type + - list_remove_unrelated_type - no_adjacent_strings_in_list + - no_literal_bool_comparisons + - no_self_assignments - omit_local_variable_types - package_api_docs + - package_prefixed_library_names - prefer_const_constructors + - prefer_const_literals_to_create_immutables + - prefer_if_elements_to_conditional_expressions - prefer_single_quotes + - public_member_api_docs - sort_child_properties_last - test_types_in_equals - throw_in_finally - unawaited_futures - - unnecessary_null_aware_assignments - unnecessary_statements - unsafe_html diff --git a/packages/process_run/example/dart_bin_version.dart b/packages/process_run/example/dart_bin_version.dart index e8795c3..1c0ce8e 100644 --- a/packages/process_run/example/dart_bin_version.dart +++ b/packages/process_run/example/dart_bin_version.dart @@ -2,10 +2,11 @@ import 'dart:async'; import 'package:process_run/cmd_run.dart'; import 'package:process_run/shell.dart'; +import 'package:process_run/stdio.dart'; Future main() async { - print('dart: ${await which('dart')}'); + stdout.writeln('dart: ${await which('dart')}'); var dartBinVersion = await getDartBinVersion(); - print('dartBinVersion: $dartBinVersion'); + stdout.writeln('dartBinVersion: $dartBinVersion'); await Shell().run('dart --version'); } diff --git a/packages/process_run/example/demo_sync.dart b/packages/process_run/example/demo_sync.dart index e3d80bd..be91ee3 100755 --- a/packages/process_run/example/demo_sync.dart +++ b/packages/process_run/example/demo_sync.dart @@ -7,7 +7,8 @@ void main() { // This is a synchronous call and will block until the child process terminates. var results = shell.runSync('echo "Hello world"'); var result = results.first; - print('output: "${result.outText.trim()}" exitCode: ${result.exitCode}'); + stdout.writeln( + 'output: "${result.outText.trim()}" exitCode: ${result.exitCode}'); // should display: output: "Hello world" exitCode: 0 // Run the command diff --git a/packages/process_run/example/flutter_bin_version.dart b/packages/process_run/example/flutter_bin_version.dart index e240c14..6d91fa6 100644 --- a/packages/process_run/example/flutter_bin_version.dart +++ b/packages/process_run/example/flutter_bin_version.dart @@ -1,10 +1,11 @@ import 'dart:async'; import 'package:process_run/cmd_run.dart'; +import 'package:process_run/stdio.dart'; import 'package:process_run/which.dart'; Future main() async { - print('flutter: ${await which('flutter')}'); + stdout.writeln('flutter: ${await which('flutter')}'); var flutterBinVersion = await getFlutterBinVersion(); - print('flutterBinVersion: $flutterBinVersion'); + stdout.writeln('flutterBinVersion: $flutterBinVersion'); } diff --git a/packages/process_run/example/info.dart b/packages/process_run/example/info.dart index d577f4f..a19da8c 100644 --- a/packages/process_run/example/info.dart +++ b/packages/process_run/example/info.dart @@ -2,11 +2,12 @@ import 'dart:async'; import 'package:process_run/cmd_run.dart' show flutterExecutablePath; import 'package:process_run/shell.dart'; +import 'package:process_run/stdio.dart'; Future main() async { - print('dartExecutable: $dartExecutable'); - print('flutterExecutablePath: $flutterExecutablePath'); - print('which(\'dart\'): ${await which('dart')}'); - print('which(\'flutter\'): ${await which('flutter')}'); + stdout.writeln('dartExecutable: $dartExecutable'); + stdout.writeln('flutterExecutablePath: $flutterExecutablePath'); + stdout.writeln('which(\'dart\'): ${await which('dart')}'); + stdout.writeln('which(\'flutter\'): ${await which('flutter')}'); await run('dart --version'); } diff --git a/packages/process_run/example/my_script.dart b/packages/process_run/example/my_script.dart index 42d600b..951b978 100644 --- a/packages/process_run/example/my_script.dart +++ b/packages/process_run/example/my_script.dart @@ -1,3 +1,5 @@ +import 'package:process_run/stdio.dart'; + void main(List arguments) { - print(arguments); + stdout.writeln(arguments); } diff --git a/packages/process_run/example/no_env_user_paths.dart b/packages/process_run/example/no_env_user_paths.dart index e62ad20..968f265 100644 --- a/packages/process_run/example/no_env_user_paths.dart +++ b/packages/process_run/example/no_env_user_paths.dart @@ -1,10 +1,11 @@ import 'dart:async'; import 'package:process_run/src/user_config.dart'; +import 'package:process_run/stdio.dart'; Future main() async { var userPaths = getUserPaths({}); for (var path in userPaths) { - print(path); + stdout.writeln(path); } } diff --git a/packages/process_run/example/prompt.dart b/packages/process_run/example/prompt.dart index 143e99f..e0fdaec 100755 --- a/packages/process_run/example/prompt.dart +++ b/packages/process_run/example/prompt.dart @@ -2,9 +2,10 @@ import 'dart:async'; import 'package:process_run/shell_run.dart'; import 'package:process_run/src/prompt.dart'; +import 'package:process_run/stdio.dart'; Future main() async { - print(await prompt('Enter your name')); - print(await promptConfirm('Action')); + stdout.writeln(await prompt('Enter your name')); + stdout.writeln(await promptConfirm('Action')); await promptTerminate(); } diff --git a/packages/process_run/example/shell/shell_common.dart b/packages/process_run/example/shell/shell_common.dart index 344b854..035c620 100644 --- a/packages/process_run/example/shell/shell_common.dart +++ b/packages/process_run/example/shell/shell_common.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'package:process_run/shell.dart'; Future main() async { diff --git a/packages/process_run/example/streamer.dart b/packages/process_run/example/streamer.dart index 07d7598..44b9aac 100755 --- a/packages/process_run/example/streamer.dart +++ b/packages/process_run/example/streamer.dart @@ -87,6 +87,7 @@ Future main(List arguments) async { await Future.delayed(Duration(microseconds: delay)); } index++; + // ignore: avoid_print print('[$index]'); } diff --git a/packages/process_run/example/user_paths.dart b/packages/process_run/example/user_paths.dart index a49a8d5..4451459 100644 --- a/packages/process_run/example/user_paths.dart +++ b/packages/process_run/example/user_paths.dart @@ -6,6 +6,6 @@ import 'package:process_run/src/user_config.dart'; Future main() async { var userPaths = getUserPaths(Platform.environment); for (var path in userPaths) { - print(path); + stdout.writeln(path); } } diff --git a/packages/process_run/lib/src/bin/shell/env_delete.dart b/packages/process_run/lib/src/bin/shell/env_delete.dart index 7e7257f..16b9af4 100644 --- a/packages/process_run/lib/src/bin/shell/env_delete.dart +++ b/packages/process_run/lib/src/bin/shell/env_delete.dart @@ -18,7 +18,7 @@ class ShellEnvDeleteCommand extends ShellEnvCommandBase { FutureOr onRun() async { var path = envFilePath; if (verbose!) { - print('envFilePath: $path'); + stdout.writeln('envFilePath: $path'); } var force = getFlag(flagForce)!; diff --git a/packages/process_run/lib/src/bin/shell/env_edit.dart b/packages/process_run/lib/src/bin/shell/env_edit.dart index 58bcda3..a4c3a5b 100644 --- a/packages/process_run/lib/src/bin/shell/env_edit.dart +++ b/packages/process_run/lib/src/bin/shell/env_edit.dart @@ -13,7 +13,7 @@ class ShellEnvEditCommand extends ShellEnvCommandBase { @override FutureOr onRun() async { if (verbose!) { - print('envFilePath: $envFilePath'); + stdout.writeln('envFilePath: $envFilePath'); } await envFileReadOrCreate(write: true); @@ -41,7 +41,7 @@ class ShellEnvEditCommand extends ShellEnvCommandBase { await doRun('vi ${shellArgument(envFilePath!)}'); return true; } - print('no editor found'); + stdout.writeln('no editor found'); return false; } } diff --git a/packages/process_run/lib/src/bin/shell/run.dart b/packages/process_run/lib/src/bin/shell/run.dart index d4ef729..2001a80 100644 --- a/packages/process_run/lib/src/bin/shell/run.dart +++ b/packages/process_run/lib/src/bin/shell/run.dart @@ -64,7 +64,7 @@ class ShellRunCommand extends ShellBinCommand { exit(1); } if (verbose!) { - print('command: $command'); + stdout.writeln('command: $command'); } await run(command); return true; diff --git a/packages/process_run/lib/src/common/dev_utils.dart b/packages/process_run/lib/src/common/dev_utils.dart index b7ce25f..9c977eb 100644 --- a/packages/process_run/lib/src/common/dev_utils.dart +++ b/packages/process_run/lib/src/common/dev_utils.dart @@ -5,6 +5,7 @@ import 'package:meta/meta.dart'; void _devPrint(Object object) { if (_devPrintEnabled) { + // ignore: avoid_print print(object); } } @@ -14,11 +15,11 @@ bool _devPrintEnabled = true; @Deprecated('Dev only') set devPrintEnabled(bool enabled) => _devPrintEnabled = enabled; -@Deprecated('Dev only') - /// Print only in dev mode +@Deprecated('Dev only') void devPrint(Object? object) { if (_devPrintEnabled) { + // ignore: avoid_print print(object); } } @@ -34,7 +35,9 @@ void _devError([Object? msg]) { throw UnsupportedError('$msg'); } catch (e, st) { if (_devPrintEnabled) { + // ignore: avoid_print print('# ERROR $msg'); + // ignore: avoid_print print(st); } rethrow; diff --git a/packages/process_run/lib/src/lines_utils_common.dart b/packages/process_run/lib/src/lines_utils_common.dart index d101df8..c84b303 100644 --- a/packages/process_run/lib/src/lines_utils_common.dart +++ b/packages/process_run/lib/src/lines_utils_common.dart @@ -87,6 +87,7 @@ Stream shellStreamLines(Stream> stream, ctlr.add(encoding!.decode(currentLine!)); } catch (_) { // Ignore bad encoding + // ignore: avoid_print print('ignoring: $currentLine'); } } @@ -97,6 +98,7 @@ Stream shellStreamLines(Stream> stream, ctlr = StreamController( onPause: () { if (shellDebug) { + // ignore: avoid_print print('onPause (paused: ${subscription?.isPaused})'); } // Last one diff --git a/packages/process_run/lib/src/process_run.dart b/packages/process_run/lib/src/process_run.dart index eed4472..9582149 100644 --- a/packages/process_run/lib/src/process_run.dart +++ b/packages/process_run/lib/src/process_run.dart @@ -82,6 +82,7 @@ Future runExecutableArguments( includeParentEnvironment: false, runInShell: runInShell); if (shellDebug) { + // ignore: avoid_print print('process: ${process.pid}'); } if (onProcess != null) { @@ -92,8 +93,10 @@ Future runExecutableArguments( () async { try { var exitCode = await process.exitCode; + // ignore: avoid_print print('process: ${process.pid} exitCode $exitCode'); } catch (e) { + // ignore: avoid_print print('process: ${process.pid} Error $e waiting exit code'); } }(); diff --git a/packages/process_run/lib/src/shell.dart b/packages/process_run/lib/src/shell.dart index b3d79b8..602c881 100644 --- a/packages/process_run/lib/src/shell.dart +++ b/packages/process_run/lib/src/shell.dart @@ -455,6 +455,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { void _clearPreviousContext() { if (shellDebug) { + // ignore: avoid_print print( 'Clear previous context ${_currentProcessResultCompleter?.isCompleted}'); } @@ -485,6 +486,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { try { if (shellDebug) { + // ignore: avoid_print print('$_runId: Before $processCmd'); } @@ -498,6 +500,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { workingDirectory: _options.workingDirectory); } finally { if (shellDebug) { + // ignore: avoid_print print( '$_runId: After $executableFullPath exitCode ${processResult?.exitCode}'); } @@ -566,6 +569,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { try { // devPrint(_options.environment.keys.where((element) => element.contains('TEKARTIK'))); if (shellDebug) { + // ignore: avoid_print print('$_runId: Before $processCmd'); } @@ -582,6 +586,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { _currentProcessCmd = processCmd; _currentProcessRunId = runId; if (shellDebug) { + // ignore: avoid_print print('onProcess ${_currentProcessToString()}'); } if (onProcess != null) { @@ -589,6 +594,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { } if (_killedRunId >= _runId) { if (shellDebug) { + // ignore: avoid_print print('shell was killed'); } _kill(); @@ -597,6 +603,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { }); } finally { if (shellDebug) { + // ignore: avoid_print print( '$_runId: After $processCmd exitCode ${processResult?.exitCode}'); } @@ -637,6 +644,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { run().then((value) { if (shellDebug) { + // ignore: avoid_print print('$runId: done'); } if (!completer.isCompleted) { @@ -644,6 +652,7 @@ abstract class Shell implements ShellCore, ShellCoreSync { } }).catchError((Object e) { if (shellDebug) { + // ignore: avoid_print print('$runId: error $e'); } if (!completer.isCompleted) { diff --git a/packages/process_run/lib/src/stdio/shell_streamer_io.dart b/packages/process_run/lib/src/stdio/shell_streamer_io.dart index a8bb8bc..13dc3a4 100644 --- a/packages/process_run/lib/src/stdio/shell_streamer_io.dart +++ b/packages/process_run/lib/src/stdio/shell_streamer_io.dart @@ -25,7 +25,7 @@ class ShellOutputLinesStreamerIo set current(bool current) { if (this.current != current) { super.current = current; - if (current == true) { + if (current) { dump(); } } diff --git a/packages/process_run/test/dart_doc_test.dart b/packages/process_run/test/dart_doc_test.dart index 2196c81..0ba4180 100644 --- a/packages/process_run/test/dart_doc_test.dart +++ b/packages/process_run/test/dart_doc_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.dartdoc_test; diff --git a/packages/process_run/test/dartbin_test.dart b/packages/process_run/test/dartbin_test.dart index d091038..5b55550 100644 --- a/packages/process_run/test/dartbin_test.dart +++ b/packages/process_run/test/dartbin_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.dartbin_test; diff --git a/packages/process_run/test/data/main.dart b/packages/process_run/test/data/main.dart index 25bea67..f3a8d74 100644 --- a/packages/process_run/test/data/main.dart +++ b/packages/process_run/test/data/main.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + void main() { print('Hello'); } diff --git a/packages/process_run/test/process_run_in_test2_.dart b/packages/process_run/test/process_run_in_test2_.dart index 71ae10e..4425968 100644 --- a/packages/process_run/test/process_run_in_test2_.dart +++ b/packages/process_run/test/process_run_in_test2_.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.process_run_in_test2_; diff --git a/packages/process_run/test/process_run_in_test_.dart b/packages/process_run/test/process_run_in_test_.dart index 2a09b6a..e273e35 100644 --- a/packages/process_run/test/process_run_in_test_.dart +++ b/packages/process_run/test/process_run_in_test_.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.process_run_in_test; diff --git a/packages/process_run/test/process_run_test.dart b/packages/process_run/test/process_run_test.dart index 84de687..cdd4874 100644 --- a/packages/process_run/test/process_run_test.dart +++ b/packages/process_run/test/process_run_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.process_run_test; diff --git a/packages/process_run/test/shell_common_test.dart b/packages/process_run/test/shell_common_test.dart index b07058b..5c38d96 100644 --- a/packages/process_run/test/shell_common_test.dart +++ b/packages/process_run/test/shell_common_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + library process_run.test.shell_common_api_test; import 'dart:async'; diff --git a/packages/process_run/test/shell_environment_test.dart b/packages/process_run/test/shell_environment_test.dart index 98affd0..4604261 100644 --- a/packages/process_run/test/shell_environment_test.dart +++ b/packages/process_run/test/shell_environment_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.test.shell_environment_test; diff --git a/packages/process_run/test/shell_run_test.dart b/packages/process_run/test/shell_run_test.dart index aaf6a24..c220053 100644 --- a/packages/process_run/test/shell_run_test.dart +++ b/packages/process_run/test/shell_run_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.test.shell_run_test; diff --git a/packages/process_run/test/shell_test.dart b/packages/process_run/test/shell_test.dart index 582e4f2..b709c6e 100644 --- a/packages/process_run/test/shell_test.dart +++ b/packages/process_run/test/shell_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.test.shell_test; diff --git a/packages/process_run/test/which_test.dart b/packages/process_run/test/which_test.dart index d6cf7b2..98e6870 100644 --- a/packages/process_run/test/which_test.dart +++ b/packages/process_run/test/which_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library process_run.which_test; diff --git a/packages/process_run/tool/manual_test_prompt.dart b/packages/process_run/tool/manual_test_prompt.dart index 57f5110..71cbed0 100644 --- a/packages/process_run/tool/manual_test_prompt.dart +++ b/packages/process_run/tool/manual_test_prompt.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'dart:async'; import 'dart:io'; diff --git a/packages/process_run/tool/run_ci.dart b/packages/process_run/tool/run_ci.dart deleted file mode 100644 index 0085485..0000000 --- a/packages/process_run/tool/run_ci.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'dart:io'; - -import 'package:process_run/shell.dart'; - -Future main() async { - var shell = Shell(); - - print(Platform.operatingSystem); - print(Platform.version); - await shell.run(''' -# Analyze code & format -dart format --set-exit-if-changed bin example lib test tool -dart analyze --fatal-infos --fatal-warnings . -# Run tests -dart test -'''); -} diff --git a/packages/process_run/tool/tag.dart b/packages/process_run/tool/tag.dart index 8535efd..ab73785 100644 --- a/packages/process_run/tool/tag.dart +++ b/packages/process_run/tool/tag.dart @@ -6,8 +6,8 @@ import 'package:process_run/shell.dart'; Future main() async { var shell = Shell(); var version = await getPackageVersion(); - print('Version $version'); - print('Tap anything or CTRL-C: $version'); + stdout.writeln('Version $version'); + stdout.writeln('Tap anything or CTRL-C: $version'); await stdin.first; await shell.run('''