Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Showing with 22 additions and 4 deletions.
  1. +7 −3 lib/jsftp.js
  2. +1 −1  package.json
  3. +14 −0 test/jsftp_test.js
View
10 lib/jsftp.js
@@ -49,8 +49,9 @@ var Ftp = module.exports = function(cfg) {
// they will be sent to the server.
this.waitingForEnqueue = [];
- for (var option in cfg)
+ for (var option in cfg) {
if (!this[option]) this[option] = cfg[option];
+ }
this.port = this.port || FTP_PORT;
@@ -85,7 +86,7 @@ Ftp.queue = function() {
}
};
return stream;
-};
+};
// Codes from 100 to 200 are FTP marks
Ftp.isMark = function(code) {
@@ -113,7 +114,6 @@ Ftp.getPasvPort = function(text) {
var self = this;
// Stream of incoming data from the FTP server.
var input = function(next, stop) {
- _socket.on("connect", self.onConnect || function(){});
_socket.on("data", next);
_socket.on("end", stop);
_socket.on("error", stop);
@@ -249,6 +249,10 @@ Ftp.getPasvPort = function(text) {
this.socket.on("connect", function() {
self.connecting = false;
self.emitter.emit("connect", "connect");
+
+ if (self.onConnect)
+ self.onConnect();
+
self._createStreams(self.socket);
if (firstTask) {
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "jsftp",
"id": "jsftp",
- "version": "0.4.7",
+ "version": "0.4.9",
"description": "A sane FTP client implementation for NodeJS",
"keywords": [ "ftp", "protocol", "files", "server", "client", "async" ],
"author": "Sergi Mansilla <sergi.mansilla@gmail.com> (http://sergimansilla.com)",
View
14 test/jsftp_test.js
@@ -364,5 +364,19 @@ describe("jsftp test suite", function() {
});
});
});
+
+ it("test attach event handlers: connect", function(_next) {
+ var clientOnConnect = function() {
+ client.auth(FTPCredentials.user, FTPCredentials.pass, function(err) {
+ assert.ok(!err);
+ client.destroy();
+ _next();
+ });
+ };
+
+ FTPCredentials.onConnect = clientOnConnect;
+
+ var client = new Ftp(FTPCredentials);
+ });
});

No commit comments for this range

Something went wrong with that request. Please try again.