-
Notifications
You must be signed in to change notification settings - Fork 15
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.
Just some general questions.
What's your use-case for this?
README.md
Outdated
A higher-level service for spawning and communicating with processes. | ||
|
||
##### Use `spawn` to create a process similar to how a bash/shell script would: |
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.
Instead of similar to how a bash/shell script would
I'd just say what it does – forwards stdout/err – and...what else?
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.
Fixed! Thanks.
|
||
// Closes stdin for the entire program. | ||
await sharedStdIn.terminate(); |
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.
What does this do, exactly? Practically speaking?
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.
Closes the underlying stdin
stream (allowing the isolate to exit).
); | ||
} | ||
|
||
class _WindowsProcessManager extends ProcessManager { |
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.
Is the idea that this would do something different at some point?
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.
Yep!
Good question. A few things really:
|
SGTM
From mobile. Sorry for brevity and/or spelling.
…On Jul 9, 2017 16:02, "Matan Lurey" ***@***.***> wrote:
I'll wait for @srawlins <https://github.com/srawlins> and @grouma
<https://github.com/grouma> to take a look since both of them are running
into cases where these utilities might be useful and I'd like some input.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABCit9UyQc01dXcu-XgxSfLBShP7a7Tks5sMVwEgaJpZM4OSNBI>
.
|
} | ||
final controller = _getCurrent(); | ||
if (controller.hasListener) { | ||
throw new StateError('' |
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.
Why the empty string? I assume for code readability but that's a pattern I haven't come across before.
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 think Natalie is actually fixing this in dartfmt, but it is the only way to force the next lines to line up. I'm OK with removing 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.
The other way to force a newline is if the string is just over 80 chars when at this indent, and under 80 chars if dartfmt is forced to drop it down to the next line.
String executable, { | ||
Iterable<String> arguments: const [], | ||
}) async { | ||
final process = io.Process.start(executable, arguments.toList()); |
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.
Should we do any error handling here? Could we run into a state where io.Process.start executes but 'await process' never resolves?
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 think we wouldn't run into any problems Process.start
doesn't already have.
lib/src/process_manager.dart
Outdated
/// | ||
/// This is _similar_ to [io.Process.start], but all standard input and output | ||
/// is forwarded/routed between the process and the host, similar to how a | ||
/// bash or shell script works. |
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 think "shell script" (minus bash) is adequate here. Unless there are popular shells that don't have the concept of stdin, 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.
Done.
lib/src/process_manager.dart
Outdated
/// A process instance created and managed through [ProcessManager]. | ||
/// | ||
/// Unlike one created directly by [io.Process.start] or [io.Process.run], a | ||
/// spawned process works more like executing a command in a shell or bash |
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 think "shell script" (minus bash) is adequate here. Unless there are popular shells that don't have the concept of stdin, 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.
Done.
test('should output Hello from another process [via stderr]', () async { | ||
final spawn = await processManager.spawn( | ||
'dart', | ||
arguments: [p.join('test', '_files', 'stderr_hello.dart')], |
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.
Have you tested whether this test works when your PWD is not the package root? test/_files/stderr_hello.dart
is relative to where you typically run pub run test, the repo root, right? I think it won't work if you are, e.g., sitting in the test directory, or at the root of some mega repo that has this as a third_party package :)
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.
For more context, I think the old way to get a relative resource was resolvePackageUri, but then package:test uses isolates, so that doesn't work. package:resource is the new way, which uses configurable imports. Alternatively, mirrors work.
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'm deferring on this one until it matters :)
* Start on process manager. * Ready for review. * Pass on .24 and .25. * Add travis badge. * Actually fix travis. * Update README. * Address feedback.
See the examples in
README.md
for a better overview of these features.Partially closes dart-lang/tools#1211.