diff --git a/packages/melos/lib/src/common/utils.dart b/packages/melos/lib/src/common/utils.dart index 6586ed04..0f22c919 100644 --- a/packages/melos/lib/src/common/utils.dart +++ b/packages/melos/lib/src/common/utils.dart @@ -222,6 +222,10 @@ class PersistentShell { late final MelosLogger _logger; late final String? _workingDirectory; late Process _process; + /// This list is intended to store the commands that are sent to the shell. + /// Currently, it is not being utilized in the code, + ///TODO: remove this or actually use it + final List _commands = []; Future startShell() async { final executable = _isWindows ? 'cmd.exe' : '/bin/sh'; @@ -232,19 +236,31 @@ class PersistentShell { workingDirectory: _workingDirectory, ); - _process.stdout.transform(utf8.decoder).listen( + _process.stdout.listen( (event) { - _logger.write(event); + _logger.logWithoutNewLine(utf8.decode(event, allowMalformed: true)); + }, + onDone: () { + /// TODO: Identify and log the specific steps that have been completed + /// successfully. + _logger.success('Shell process completed some steps successfully.'); }, ); - _process.stderr.transform(utf8.decoder).listen( - (data) { - _logger.write(data); + _process.stderr.listen( + (event) { + _logger.error(utf8.decode(event, allowMalformed: true)); + }, + onDone: () { + /// TODO: Identify and log the specific steps that have completed + /// with errors. + _logger.error('Shell process completed with errors.'); }, ); } void sendCommand(String command) { + _commands.add(command); + final formattedScriptStep = targetStyle( command.addStepPrefixEmoji().withoutTrailing('\n'), );