-
Notifications
You must be signed in to change notification settings - Fork 81
[MV3 Debug Extension] Compile extension with Dart instead of shell script #1954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Elliott, added some comments
void logOutput(ProcessResult result) { | ||
final output = result.stdout; | ||
final outputList = output is List ? output : [output ?? '']; | ||
print(outputList.map((output) => '$output').join('\n')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we switch to using transformers on the stream to listen to lines instead and logging them one by one? That way we can see the output in progress, even if the process never ends, for example. Also it will allow us to fail early if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the documentation:
"Use the static start and run methods to start a new process. The run method executes the process non-interactively to completion. In contrast, the start method allows your code to interact with the running process."
Process.start
returns a Process
with stdout
and stderr
streams that can be listened to. I think it makes more sense to use Process.run
here.
), | ||
); | ||
logInfo('Updating manifest.json in /compiled directory.'); | ||
logOutput( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add printing on errors, for example if the exist code is not 0? Or maybe return the exit code from run
so the caller can check it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, now checking if the exit code is not 0, and is so printing the stderr
.
} | ||
|
||
void logOutput(ProcessResult result) { | ||
final output = result.stdout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to log the stderr as well.
Suggestion - use transformers to listen to both and use a logger to report severe errors on failures (for example, any message from stderr, non-0 exit codes, or [SEVERE] output on stdout)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging stderr
if the exit code is not 0, and also terminating the entire process with that exit code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Elliott, left some small comments
); | ||
final updateExitCode = await _handleProcess(updateStep); | ||
// Terminate early if updating dev files failed: | ||
if (updateExitCode != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return updateExitCode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can we log that the process exited abnormally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateExitCode is being returned, and logging happens in main (line 29-30)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that this logic (lines 53-57) can be simplified to just "return updateExitCode`, but that is optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done
); | ||
final updateExitCode = await _handleProcess(updateStep); | ||
// Terminate early if updating dev files failed: | ||
if (updateExitCode != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that this logic (lines 53-57) can be simplified to just "return updateExitCode`, but that is optional
} | ||
|
||
void logWarning(String message) { | ||
print('[WARNING] $message'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional - should we just use a logger(from package:logging/logging.dart) instead of printing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change [WARNING] to [ERROR], to indicate irrecoverable failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now writing to sdout/stderr following example in https://dart.dev/tutorials/server/cmdline (package:logging/logging.dart
wasn't logging to console)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Work towards #1724, #1950