Skip to content
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

Add method to prefix following calls to transport #4

Closed
wants to merge 12 commits into from

Conversation

reaktivo
Copy link

Added method to solve the problem of needing to prefix calls to transport with another function. You can now do this:

transport.chdir(path, function() {
  transport.git('pull');
  transport.npm('install');
});

which would be the same as calling

transport.exec('cd my-path && git pull');
transport.exec('cd my-path && npm install');

Fixes #2

@pstadler
Copy link
Owner

Thanks for your effort.

There are a couple of things that I want to further investigate regarding interactive shells. Besides that I have a similar solution which I didn't push yet:

transport.with(cmd|options[, options], fn);

// Example 1:
transport.with('cd foo', fn); // prepend 'cd foo && ' to commands inside fn
// Example 2:
transport.with({silent: true}, fn); // commands inside fn are executed with silent=true
// Example 3:
transport.with('cd foo', {silent: true}, fn); // 1+2 together

The code works, but I'm holding it back until I figured out how the logging should work inside these blocks and if this makes sense at all.

What do you think?

@reaktivo
Copy link
Author

I think your solution is a lot more elegant. I hope it does get merged. The documentation should just be explicit about the behaviour in the case that the exec calls inside the with fn get called with their own options. Also, for clarity, I feel it's the best to have the log actually log the complete command including the "prefix"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make remote.cd work
2 participants