Use the per-user Docker socket as the Unix default, if present #157
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #156. On Mac and Linux, if
$HOME/.docker/run/docker.sock
is present, that will be used by default. If not, the previous/var/run/docker.sock
will be used instead.This needs to change a few things, because the check for this is async. To make that work,
socketPath
can now be a function that returns a promise, in which case this will be run and awaited duringdial
.This shouldn't be a breaking change, but it probably is because (just searching around GitHub) there's quite a few projects that look at
modem.socketPath
directly to see which path was detected. Fortunately it looks like you're already on track for a v4 breaking release anyway, so we can sneak this in there too 😄.To make that change easier for downstream users, and to simplify the internals too, this adds a new
getSocketPath
method, which always returns eitherundefined
(if no socket path is used - e.g. for remote hosts & SSH) or a promise that should resolve to the path.Anybody who wants the path can use
socketPath = await modem.getSocketPath()
and they'll always get either a string or undefined.Sound reasonable?
There is another way to implement this, by changing the API completely to replace the simple
new Modem
constructor with an asyncbuildModem
method that returns a promise. In that case, we could calculate the socketPath during the method, and then everything after that resolved would just be synchronous. That's a bit cleaner in some ways (no new async steps during dial, socketPath is always just a string or undefined) but it's a bigger breaking change so I've avoided it here. Let me know if you'd prefer that.