Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicatarra committed Jun 23, 2024
1 parent d48e505 commit e7fb6dc
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions packages/melos/lib/src/common/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> _commands = [];

Future<void> startShell() async {
final executable = _isWindows ? 'cmd.exe' : '/bin/sh';
Expand All @@ -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'),
);
Expand Down

0 comments on commit e7fb6dc

Please sign in to comment.