Comparing version 0.3.0 to 0.3.1
35
index.js
var spawn = require('child_process').spawn, | ||
_ = require('underscore'); | ||
var escapeshell = function(cmd) { | ||
return cmd.replace(/(["\s'$`\\])/g,'\\$1'); | ||
}; | ||
/* | ||
@@ -33,5 +29,6 @@ ** Params : | ||
username: '', | ||
password: '' | ||
password: '', | ||
escape: true, | ||
}; | ||
var opts = _.pick(_.extend(defaults, options), 'host', 'username', 'password', 'port'); | ||
var opts = _.pick(_.extend(defaults, options), 'host', 'username', 'password', 'port', 'escape'); | ||
if (!opts.host) throw new Error('You need to set a host.'); | ||
@@ -47,2 +44,8 @@ if (!opts.username) throw new Error('You need to set an username.'); | ||
FTP.prototype.escapeshell = function(cmd) { | ||
if (this.options.escape) | ||
return cmd.replace(/(["\s'$`\\])/g,'\\$1'); | ||
return cmd; | ||
}; | ||
FTP.prototype.exec = function (cmds, callback) { | ||
@@ -58,3 +61,3 @@ if (typeof cmds === 'string') | ||
var cmd = ''; | ||
cmd += 'open -u "'+ escapeshell(this.options.username) + '","' + escapeshell(this.options.password) + '" "' + this.options.host + '";'; | ||
cmd += 'open -u "'+ this.escapeshell(this.options.username) + '","' + this.escapeshell(this.options.password) + '" "' + this.options.host + '";'; | ||
cmd += this.cmds.join(';'); | ||
@@ -92,4 +95,4 @@ this.cmds = []; | ||
FTP.prototype.pwd = function () { return this.raw('pwd'); }; | ||
FTP.prototype.cd = function (directory) { return this.raw('cd ' + escapeshell(directory)); }; | ||
FTP.prototype.cat = function (path) { return this.raw('cat ' + escapeshell(path)); }; | ||
FTP.prototype.cd = function (directory) { return this.raw('cd ' + this.escapeshell(directory)); }; | ||
FTP.prototype.cat = function (path) { return this.raw('cat ' + this.escapeshell(path)); }; | ||
FTP.prototype.put = function (localPath, remotePath) { | ||
@@ -99,4 +102,4 @@ if (!localPath) | ||
if (!remotePath) | ||
return this.raw('put '+escapeshell(localPath)); | ||
return this.raw('put '+escapeshell(localPath)+' -o '+escapeshell(remotePath)); | ||
return this.raw('put '+this.escapeshell(localPath)); | ||
return this.raw('put '+this.escapeshell(localPath)+' -o '+this.escapeshell(remotePath)); | ||
}; | ||
@@ -108,4 +111,4 @@ FTP.prototype.addFile = FTP.prototype.put; | ||
if (!localPath) | ||
return this.raw('get '+escapeshell(remotePath)); | ||
return this.raw('get '+escapeshell(remotePath)+' -o '+escapeshell(localPath)); | ||
return this.raw('get '+this.escapeshell(remotePath)); | ||
return this.raw('get '+this.escapeshell(remotePath)+' -o '+this.escapeshell(localPath)); | ||
}; | ||
@@ -116,9 +119,9 @@ FTP.prototype.getFile = FTP.prototype.get; | ||
return this; | ||
return this.raw('mv ' + escapeshell(from) + ' ' + escapeshell(to)); | ||
return this.raw('mv ' + this.escapeshell(from) + ' ' + this.escapeshell(to)); | ||
}; | ||
FTP.prototype.move = FTP.prototype.mv; | ||
FTP.prototype.rm = function () { return this.raw('rm ' + Array.prototype.slice.call(arguments).map(escapeshell).join(' ')); }; | ||
FTP.prototype.rm = function () { return this.raw('rm ' + Array.prototype.slice.call(arguments).map(this.escapeshell).join(' ')); }; | ||
FTP.prototype.remove = FTP.prototype.rm; | ||
FTP.prototype.rmdir = function () { return this.raw('rmdir ' + Array.prototype.slice.call(arguments).map(escapeshell).join(' ')); }; | ||
FTP.prototype.rmdir = function () { return this.raw('rmdir ' + Array.prototype.slice.call(arguments).map(this.escapeshell).join(' ')); }; | ||
module.exports = FTP; |
{ | ||
"name": "ftps", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name" : "Sébastien Chopin" , |
@@ -31,2 +31,3 @@ node-ftps | ||
// port is added to the end of the host, ex: sftp://domain.com:22 in this case | ||
escape: true, // optional, used for escaping shell characters (space, $, etc.), default: true | ||
}); | ||
@@ -33,0 +34,0 @@ // Do some amazing things |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
8129
5
0
111
88