Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 36 additions and 1 deletion.
  1. +14 −1 index.js
  2. +22 −0 readme.md
View
15 index.js
@@ -13,7 +13,12 @@ module.exports = function (options) {
var fileCount = 0;
var remotePath = options.remotePath || '';
+ var localPath = options.localPath || '';
+ var logFiles = options.logFiles === false ? false : true;
+
delete options.remotePath;
+ delete options.localPath;
+ delete options.logFiles;
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
@@ -29,7 +34,8 @@ module.exports = function (options) {
// have to create a new connection for each file otherwise they conflict
var ftp = new JSFtp(options);
var relativePath = file.path.replace(file.cwd + '/', '');
- var finalRemotePath = path.join('/', remotePath, relativePath);
+ var localRelativePath = file.path.replace(path.join(file.cwd, localPath), '');
+ var finalRemotePath = path.join('/', remotePath, localRelativePath);
ftp.mkdirp(path.dirname(finalRemotePath), function (err) {
if (err) {
@@ -43,6 +49,13 @@ module.exports = function (options) {
return cb();
}
+ if (logFiles) {
+ gutil.log('gulp-ftp:', gutil.colors.green('Uploaded: ') +
+ relativePath +
+ gutil.colors.green(' => ') +
+ finalRemotePath);
+ }
+
fileCount++;
ftp.raw.quit();
cb();
View
22 readme.md
@@ -64,6 +64,28 @@ The remote path to upload too.
Doesn't have to exist as [jsftp-mkdirp](https://github.com/sindresorhus/jsftp-mkdirp) is used.
+#### options.localPath
+
+Type: `String`
+Default `'.'`
+
+The local path to upload from.
+This is useful for example when you use
+
+```javascript
+gulp.src('_public/js/*').pipe({remotePath: '/www/some/path'});
+```
+
+And you want the contents of `_public/js` to be uploaded to
+`/www/some/path`, but not `_public/js` itself. Then you just set
+`localPath` to `_public/js` and you are done.
+
+#### options.logFiles
+
+Type: `Boolean`
+Default: `true`
+
+Logging of files as they are uploaded. If set to false, you will only see a message when all files finished.
## License

No commit comments for this range

Something went wrong with that request. Please try again.