Giter VIP home page Giter VIP logo

vinyl-ftp's People

Contributors

alexjebens avatar hmalphettes avatar jandob avatar jmarceli avatar morris avatar rzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vinyl-ftp's Issues

Check whether directory exists before calling mkdir

Is it possible to check whether a directory exists before calling mkdir? I'm writing a gulp upload script which fails after the first run as it attempts to recreate an already existing directory. I can't delete the remote directory as the ftp user does not have permission to delete remote files, only to create new files/directories.

Code's pretty standard but adding in case it's helpful

gulp.task('upload-only', function() {
        var conn = getFtpConnection();
        return gulp.src(['code_drop/RetailGuardian.zip'], { base: '.', buffer: false } )
                .pipe( conn.dest('/RetailGuardian') );
});

Error: unable to verify the first certificate

Now I realise this might not be the issue of vinyl-ftp, but I am having a hard time understanding what is happening here. I have FTP configuration:

// config-ftp.js

module.exports = {
    host: 'ftp.xxxx.xx',
    user: '[email protected]',
    password: 'somepwd',
    parallel: 10,
    secure: true,
    secureOptions: true,
    log: require('gulp-util').log
};

Here is the task (just in case):

var gulp = require('gulp'),
    ftp = require('vinyl-ftp'),
    config = require('config-ftp');

gulp.task('deploy', function () {

    var conn = ftp.create(config);

    return gulp.src('build/**', {
            base: './',
            buffer: false
        })
        .pipe(conn.newer('/'))
        .pipe(conn.dest('/'));

});

This is the error I get:

ERROR Error: unable to verify the first certificate
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1016:38)
    at emitNone (events.js:67:13)
    at TLSSocket.emit (events.js:166:7)
    at TLSSocket._finishInit (_tls_wrap.js:585:8) (UNABLE_TO_VERIFY_LEAF_SIGNATURE)

Specify connection's active or passive mode?

Hello. I'm looking to use this to deploy to a server (that I don't control) with a slightly finicky connection. Is there a way to specify Active or Passive mode?

There's conn.mode( remoteFolder, mode[, options], but that seems to do something else. Some GUI clients provide an Active/Passive toggle but, to my knowledge, the ftp command doesn't, so maybe I'm out of luck.

Mode does not apply

Hi again ^^

Then, the mode method does not apply my 0777 mode. I verified the directory and it's good.

excluding files with !

Took me a long time to learn this. I don't know if it's gulp related or your program related, but it would be really really helpful if this was added to the documentation for anyone else who is not as knowledgeable, like me!

thanks for plugin though, it rules

MLSD - '500 Command not understood.

I'm getting an error '500 Command not understood.

I'll paste the full error message below. This issue seems very similar to #4. Which was closed per v0.3.3. But I'm using vinyl-ftp v0.4.5 (e.g. the current one on npm).

I used this project because it was referenced from gulp-ftp and that was deprecated. However I got my files uploaded using gulp-ftp with the same settings.

Upload to different folder structure that locally

I have a folders locally for all my assets called /assets/_dist, on my remote server i have an assets folder called /assets.

How can i upload the content of /assets/_dist to my remote /assets folder?

I've tried a few things, but i always get paths like /assets/_dist/js/frontend.min.js or /assets/assets/_dist/js/frontend.min.js when what i want is /assets/js/frontend.min.js.

Currently i have this, but it's not working at all, and i cannot figure out what i need to change.

var ftpConn = ftp.create( {
        host: sftpConfigContent.host,
        user: sftpConfigContent.user,
        password: sftpConfigContent.password,
        parallel: 10,
        log: gutil.log
});
var globs = [
    'assets/_dist/js/**',
    'assets/_dist/css/**'
];

gulp.task( 'ftp-css', function () {
     return gulp.src( globs, { base: '/files/templates/designs/mydesign/assets', buffer: false } )
         .pipe( ftpConn.newer( '/assets/_dist' ) ) // only upload newer files
         .pipe( ftpConn.dest( '/files/templates/designs/mydesign/assets' ) );
 } );

Any tips on what i should change are welcome.

Gulp Notify Support

Just curious if there is a way to attach error/success messages to gulp-notify. If not, is that something you'd consider adding?

Thanks!

Unable to upload on a several seconds interval

Hello,

First, thanks for your script. I have a problem when I try to upload with a 30 second interval.
We work sometime directly on the server so we need the compiled CSS on the FTP. We work with libsass too.

Here is my script. On stackoverflow they talk about the base parameter. http://stackoverflow.com/questions/29340264/vinyl-ftp-does-no-upload

var site_path = './sites/site1/t/assets/';
var admin_path = './admin/t/assets/';

 var globs = [
        site_path +'css/**',
        admin_path +'css/**'
    ];

    return gulp.src( globs, { base: '.', buffer: false } )
        .pipe( conn.dest( '/' ));

In my watch task when it works I have

CONN
READY
LIST
PUT
DISC
UP

When it doesn't works PUT and UP are not here.

What do you think ?

Upload is ignoring subdirectories

gulp.task( 'deploy', function () {
var conn = ftp.create( {
host: ftp_host,
user: ftp_login,
password: ftp_pass,
parallel: 10,
log: gutil.log
});

var globs = [
    'dist/wp-content/**/*'
];

return gulp.src( globs, { base: 'dist', buffer: false } )
    .pipe( conn.dest( staging_url ) );

Everything seems to work fine on upload, but anything under a subdirectory is ignored.

For example, in a structure such as /foo/bar/, all files under /foo/ are uploaded, and /bar/ is created, but nothing in /bar/ is uploaded.

Any idea what's going on here?

Vinyl uploads all the content even when it is not newer

I've created the following task.

gulp.task('deploy', function() {
    var conn = ftp.create({
        host: 'xxxx.com',
        user: '[email protected]',
        password: 'xxxx',
        log: gutil.log
    });

    return gulp.src('dist/**', {
            buffer: false
        })
        .pipe(conn.newer('/')) // only upload newer files
        .pipe(conn.dest('/'))
        .pipe(notify({
            message: 'Finished deployment.',
            onLast: true
        }));
});

The problem is that it always uploads all the content even if I have changed nothing.. I don't know if I am doing anything wrong.

conn.close() or something similar?

Sorry for spamming with issues/questions, but I got another one:

So the general flow of my gulp task is that it watches for changes on local files. If file changes it does the following:

  • opens connection
  • deploys the file
  • sets permission on that file
var conn = ftp.create({[params removed for brevity]});
gulp.src(['build/' + fileChanged])
        .pipe(conn.dest('../usr/local/www/' + destFolder))
        .pipe(setPermissions(conn, destFolder, fileChanged));

... where setPermissions essentially does this:

var filePermission = getPermission(fileChanged);
conn.chmod('../usr/local/www/' + fileChanged, filePermission, function() {
    console.log('permission', filePermission, 'is set for file', fileChanged);
});

What this code misses is closing of the connection. Because of that, eventually gulp stops deploying files with the following error:

ERROR : Error: There are too many connections from your internet address.
    at makeError <C:[project path]\node_modules\vinyl-ftp\node_modules\ftp\lib\connection.js:1067:13>

Notice, that due to the fact that I'm using conn.chmod, I can't pass options with { keep: false }, to tell vinyl-ftp to close connection after permissions are set. I need a way to close connection somehow differently.
it'd be great if there was an api call conn.close()

As usual, any help is appreciated.

how can i reflush the exists folder

my code:

var conn = ftp.create(config['tmt_preview']);
gulp.src('./dist/**/*.*', {base: '.', buffer: false})
       .pipe(conn.newerOrDifferentSize('/project'))
       .pipe(conn.dest('/project'));

console:
image

first run everything is ok, take some change, run gulp ftp again, and you can see: the process not exit, and remotePath can not reflush, may i make anything wrong? help. thanks!

Error: read ECONNRESET

Hello,

We are trying to setup vinyl-ftp for quick deployment within our process. We separate our Development (Gulp Files, JS, LESS etc) then have our main site folder in a 'Site Files' folder. The setup for our deploy is as follows:

gulp.task( 'deploy', function() {
    var conn = ftp.create( {
        // username, host, pass etc.
        parallel: 1,
        maxConnections: 1,
        log:      gutil.log
    } );

    var globs = [
        '../Site Files/assets/**'
    ];

    // using base = '.' will transfer everything to /public_html correctly
    // turn off buffering in gulp.src for best performance

    return gulp.src( globs, { base: '.', buffer: false } )
        .pipe( conn.newer( '/public_html' ) ) // only upload newer files
        .pipe( conn.dest( '/public_html' ) );

} );

Every time we run the task we get an error:
CONN
READY
MSLD /Site Files
ERROR Error: read ECONNRESET
at exports._errnoException (util.js:746:11)
at TCP.onread (net.js:559:26) (ECONNRESET)
DISC

Do you know what this could be?

We have a limit of 3 connections to the host, that is why we limit parallel/MaxConnections to 1 to stop the limit being hit a lot.

Thanks

conn.chmod( path, mode, callback) does not exactly work

I have the following code running in gulp:

conn.chmod('myFile', '4755', function(){ console.log('changed'); });

it almost works. If I go the the terminal and run the following command ll myFile I'd get -rwxr-xr-x. However, if I directly run on the terminal chmod 4755 myFile, I'll get -rwsr-xr-x, which is what expected.

Any help is appreciated

Download only newer files

Is there a possibility to download only newer files? I tried gulp-newer and gulp-changed - but neither of them work, because the vinyl-ftp file objects have no .stat.

gulp-newer

  return conn.src(src, opts)
    .pipe(newer('.'))
    .pipe(gulp.dest('.'));

Output:

      throw er; // Unhandled 'error' event
      ^
Error: Expected a source file with stats

gulp-changed

  return conn.src(src, opts)
    .pipe(changed('.'))
    .pipe(gulp.dest('.'));

Output:

            if (sourceFile.stat.mtime > targetStat.mtime) {
                               ^

TypeError: Cannot read property 'mtime' of null

Vinyl FTP keeps creating new connections

Regardless of the connection options the task creates more then 1 connection.

var conn = ftp.create( {
                parallel: 1,
                maxConnections: 1,
                secure: true,
                reload: true,
                secureOptions: { rejectUnauthorized: false },
                log:      gutil.log
        } );

The copy starts and then in the middle of the task I get following error:

... some files have been uploaded already ...
[07:52:38] 'deploy' errored after 27 s
[07:52:38] Error: Unable to make data connection
    at Socket.<anonymous> (----/main/master/node_modules/vinyl-ftp/node_modules/ftp/lib/connection.js:935:10)

Why is new connection created?

Going through all folder in base dir...

Hi, i'm trying to figure out hot to upload only the file saved.
I have a task that watch when i save a file.

I'm working on a wordpress theme but when the uploading task start it seem to go and verify all folder and file if has changed. I have many file and folder and it's taking long time to finish.

So is there a way to upload only the file that has be just saved?
Thanks

Ignoring Files

Is there a way to specify files to be ignored by the upload (like a ".ftpignore" file, or something similar)?

Mode API

#5 "Then, what is the utility of having a remoteFolder option for mode?"

Good question - It's used in combination with the relative paths of incoming vinyl files. Not sure whether I could remove it and just use the absolute paths.

However I think the best solution would be an API like "conn.mode( globs, mode )" that just globs and chmods in one go. The gulp/stream way does not have any benefits here. Will keep this issue open for some time and then decide what to do with it.

Does not upload some files

I'm running into a weird issue. With all of my projects I never had this problem. I'm trying to upload a simple list of files :

'application/**',
'cache/*',
'css/**',
'js/**',
'vendor/**',
'.htaccess',
'index.php',

But it keeps only uploading vendor/**. If I remove it, it doesn't upload anything. Adding ./ at the beginning of the path doesn't change anything either.

Have you got some thoughts on how to debug this?

Rename uploaded file

Hello, there is an way to rename an uploaded file?

return gulp.src('some/file.zip', {buffer: false})
                .pipe(conn.dest('/new_name.zip'));

Showing progress

Is there anyway - it would be enough to show each file as it is being copied

Clean destination directory

Hi, is there a way to clean (empty) the FTP destination directory before the transfer begins?
It could be useful, I think...

"MLSD not understood" error

Hi!

I don't know what I do wrong but I can't upload any file, all my tests ended with ERROR { [Error: MLSD not understood] code: 500 }.

Here my task, hope it will help :

gulp.task('deploy', ['css', 'js', 'images'], function(){

    var json = require('./config/ftp.json'),
        conf = prod ? json.prod : json.dev,
        conn = ftp.create({
            host: conf.host,
            user: conf.user,
            password: conf.pass,
            //parallel: 10,
            log: gutil.log
        });

    return gulp.src('components/', { base: '.', buffer: false })
        .pipe(plumber())
                // My dest is /pinon_dev
        .pipe(conn.newer(conf.dest))
        .pipe(conn.dest(conf.dest));

});

Thanks for the great work, anyway ;)

conn.src Since option is ignored

In fact, looks like whole the VinylFtp.src method is not being executed:

  • using gulp (gulp.src)
  • without gulp, as per docs (fs.src)

It is, however when using ftp.src but then files are not transferred (there's just MLSD command)

Version 0.4.1

Maybe the solution is to move this functionality out of src module into new newerThan method in filters like so:

    newerThan: function ( folder, options) {

        options = this.makeOptions( options );
        return this.filter( folder, function ( file, remote, cb ) {

            cb(null, !remote || file.stat.mtime > options.since );

        }, options );

    },

Another problem I found is that the remote variable (used in filter) is always undefined (because of this), so all comparisons evaluate to true,

When I change the callback to cb(null, files), I see that the files listed (so compared to later) are on the root of remote server, which doesn't help much.

solution could be to use just one method for source and destination or pass local and remote path as a constructor option.

Sorry for rolling upside down, I've searched interwebz for this feature and I'm not going back to Phing.

Delete folder

I am trying to empty out a folder with this library and recreating it after.

conn.rmdir(remotePath + '/**');
Is this the line needed to remove all content in the folder, or does it only delete the folder itself, please , this requires more documentation.

SSL support?

I'm getting ERROR Error: Policy requires SSL.

It looks like there's no support for SSL?

clean

There should be clean stream that globs remote files and deletes any that don't exist locally. See this example use case.

TypeError: Cannot read property 'substr' of undefined

After switching from gulp-ftp, I have this task specified according to your docs:

gulp.task('ftp', function () {
    return gulp.src('.')
        .pipe(plugins.prompt.prompt({
            type: 'password',
            name: 'pw',
            message: 'enter ftp password'
        }, function(result) {
            var conn = ftp.create({
                host:     config.ftp.host,
                user:     config.ftp.user,
                password: result.pw,
                parallel: 1,
                log: gutil.log
            });

            return gulp.src([dirs.dist + '**/*'], { base: '.', buffer: false } )
                .pipe(conn.newer('/')) // only upload newer files
                .pipe(conn.dest('/'));
        }));
});

but only get this error when running it:

[gulp] Starting 'upload'...
[?] enter ftp password: *******
[gulp] Finished 'upload' after 7.05 s
[19:27:01] CONN 
[19:27:01] READY
[19:27:01] MLSD  /dist
/Volumes/USR/xxxx/Projects/Homepage/node_modules/vinyl-ftp/lib/mlsd.js:93
          var year = modify.substr( 0, 4 );
                           ^
TypeError: Cannot read property 'substr' of undefined
    at /Volumes/USR/xxxx/Projects/Homepage/node_modules/vinyl-ftp/lib/mlsd.js:93:28

FTP Hangs on MLSD Command

I have used this module for a while,,

Suddenly it stopped working, always hangs on MLSD command,

Here is shell output,

[13:44:49] CONN 
[13:44:49] READY
[13:44:49] MLSD  /public_html
[13:45:14] ERROR Error: read ETIMEDOUT
    at exports._errnoException (util.js:746:11)
    at TCP.onread (net.js:550:26) (ETIMEDOUT)
[13:45:14] DISC 

BTW filezilla is working without issues - so it's not port range issue as suggested here and there,,,,

Set Permissions on Folder

I know that conn.mode() command sets permissions on files.
How can I set permissions on the folder?

'newer' only works every other time

I tried everything I could think of and googled a lot, but I cannot solve this issue:
The file index.html gets uploaded only every other time, regardless whether it has been changed or not.
This seems to affect files in the root-directory only.

ftp-vinyl

I highlighted the MLSD-command, because this might be a clue: the root is only listed every other time.

Any help would be greatly appreciated!

Error: Considering directory a file + sometimes cannot find local dirs

Task:

gulp.task('deploy', function () {
  var connection = ftp.create({
    host: '***',
    user: '***',
    pass: '***',
    log: $.util.log
  });

  return gulp.src(PATHS.build.dist.basePath + '**/*', { buffer: false })
    //.pipe(connection.newer('/'))
    .pipe(connection.dest('/'));
});

First deploy runs sometimes OK, sometimes errors with:

[17:34:07] Error: /jspm_packages/github/smajl/bootstrap@master/dist: No such file or directory

But the directory is always there. Anyway after completing deploy I get this on every next try:

[17:29:24] Starting 'deploy'...
[17:29:24] CONN 
[17:29:24] CONN 
[17:29:24] CONN 
[17:29:24] READY
[17:29:24] PUT   /index.html
[17:29:24] READY
[17:29:24] PUT   /jspm.conf.js
[17:29:24] READY
[17:29:24] MLSD  /
[17:29:24] UP    100% /index.html
[17:29:24] UP    100% /jspm.conf.js
[17:29:24] LIST  /
[17:29:24] ERROR [Error: /images is a file, cannot MKDIR]
[17:29:24] DISC 
[17:29:24] 'deploy' errored after 203 ms

Any idea? I deploy with gulp-ftp with same setup with no problem. :(

idleTimeout issue

Hi,

Thank you for your job. I recently face a server that every upload takes too much time. It seems to me that is a ideTimeout issue.

Are you considering to add a keepalive feature. Because the thing that is delaying the process si the CONN

Thank you!

how to do something once upload finished?

this may be a noob questions, so please be gentle :)

it seems that .dest() emits files immediately, which is certainly preferred in some cases.
I want to trigger a browsersync reload once the upload is complete (once per file, or once per stream)

Error: Create directory operation failed

my code:

return gulp.src('./dist/**/*', {base: '.', buffer: true}).pipe(conn.dest(dir))

the error message: Error: Create directory operation failed.

help me, please!

Error: Can't create directory: Permission denied (connection.js?)

Hello, thanks in advance to anyone reading!

I can't seem to get around this error.

I'm pretty new to this stuff, so I'm hoping it's just a quick fix?

command line report

[path] $ gulp deploy
[20:52:37] Using gulpfile [path]/gulpfile.js
[20:52:37] Starting 'deploy'...
[20:52:37] CONN 
[20:52:37] CONN 
[20:52:38] READY
[20:52:38] MLSD  /
[20:52:38] READY
[20:52:38] MLSD  /_public
[20:52:38] MKDIR /_public
[20:52:38] CONN 
[20:52:38] 'deploy' errored after 1.22 s
[20:52:38] Error: Can't create directory: Permission denied
    at makeError ([path]/node_modules/vinyl-ftp/node_modules/ftp/lib/connection.js:1067:13)
    at Parser.<anonymous> ([path]/node_modules/vinyl-ftp/node_modules/ftp/lib/connection.js:113:25)
    at Parser.emit (events.js:110:17)
    at Parser._write ([path]/node_modules/vinyl-ftp/node_modules/ftp/lib/parser.js:59:10)
    at doWrite (_stream_writable.js:301:12)
    at writeOrBuffer (_stream_writable.js:288:5)
    at Parser.Writable.write (_stream_writable.js:217:11)
    at Socket.ondata ([path]/node_modules/vinyl-ftp/node_modules/ftp/lib/connection.js:273:20)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
[20:52:38] MLSD  /_public/_css
[20:52:38] MLSD  /_public/_img
[20:52:38] DISC 
[20:52:38] DISC 
[20:52:39] READY
[20:52:39] MLSD  /_public/_icons
[20:52:39] DISC

my gulpfile

var gulp = require( 'gulp' );
var gutil = require( 'gulp-util' );
var ftp = require( 'vinyl-ftp' );

gulp.task( 'deploy', function() {

    var conn = ftp.create( {
        host:     '[host]',
        user:     '[user]',
        password: '[password]',
        parallel: 10,
        log:      gutil.log
    } );

    var globs = [
        '_public/**'
    ];

    // using base = '.' will transfer everything to /public_html correctly
    // turn off buffering in gulp.src for best performance

    return gulp.src( globs, { base: '.', buffer: false } )
        .pipe( conn.newer( '.' ) ) // only upload newer files
        .pipe( conn.dest( '.' ) );

} );

Upload going to wrong folder

My FTP user is already linked to the correct folder, and I am uploading everything in my app folder. But my files are being uploaded into a a folder called app even though I tell it not to.

 var globs = ['app/**'];
    return gulp.src(globs, {base: 'dist', buffer: false}).pipe(conn.dest('./'));

There is no option to exclude folder from local path.

Hi! I'd like to explaine, what I mean in title.
Let's say, that I have this ierarchy:

/
  app
  dist
  gulpfile.js

So I want to all files from 'dist' (for 'distribution', with optimized files) folder be copied to my server path. Let it be 'www/domainname'
When I tried to add ['./dist/**/*'] as my globs variable, it copies 'dist' folder itself.

The only way to solve this problem for now is to rename 'dist' folder to 'domainname' and they'll match. But this approach is bad for me (and I believe, for others too), because of the debugging all places, where 'dist' folder was mentioned. Thanks in advance!

how to exclude root local folder?

I have my local files for deployment in ./dist

Currently, I am using this gulp script:

gulp.task('deploy', ['prompt_password'], function() {
  var conn = ftp.create({
    host: 'myhost',
    user: 'userName',
    password: userPass,
    parallel: 10,
    log: gutil.log
  });
  var globs = [
    'dist/**'
  ];

  return gulp.src(globs, {
      base: '.',
      buffer: false
    })

    .pipe(conn.dest('/sandbox/myApp'));

});

This correctly uploads everything in dist as it should to my /sandbox/myApp directory -- EXCEPT it also creates the dist folder in there, so now my URL is myserver.com/sandbox/myApp/dist/index.html

Not horrible, but can it be avoided?

missing module lodash

I get the following error trying to gulp deploy
I installed lodash globally and in the project folder

module.js:338
    throw err;
          ^
Error: Cannot find module 'lodash._getnative'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/PATH_TO_MY_PROJECT/node_modules/gulp/node_modules/gulp-util/node_modules/lodash.template/node_modules/lodash.keys/index.js:9:17)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)

Upload a file in different folder

Hello
I'm trying to upload files inside a different remote folder than the local one.
For instance, I have a local file /build/index.html and I would like to deploy it on the root of the FTP /index.html and not inside remote "build" folder. Is there a way to achieve that? I'm playing with different combination of options but with no success so far...
Thanks

Improve README.md to warn about pushing gulpfile.js to public repo

thanks for this great tool! i started using it with pleasure, however, realized that a security pitfall could be for noobs like me to expose ftp credentials when pushing their project gulpfile.js to a public repo. you could point that out in README.md โ€“ but nevermind ;-)

Delete remote folder before uploading?

Hi there,

I'm using your plugin in a gulp workflow described here:
https://discourse.roots.io/t/deploy-to-production-server-on-shared-hosting-with-gulp-with-ftp/4435/5

What I would like to do is to delete a remote folder, before the uploading starts. So I added the conn.rmdir option in my following code:

// ### Vinyl FTP
var ftppass = require('./.ftppass.json');
gulp.task('upload', function(cb) {
  var conn = ftp.create( ftppass );
  var globs = [
    '*',
    '*.php',
    'dist/**',
    'lang/**',
    'templates/*.php',
    'lib/*.php',
    '!.ftppass.json',
    '!.git',
    '!*.json',
    '!*.md',
    '!*.xml',
    '!assets',
    '!bower_components',
    '!dist/scripts/jquery.js',
    '!dist/scripts/jquery.js.map',
    '!dist/scripts/main.js',
    '!dist/scripts/main.js.map',
    '!dist/scripts/modernizr.js',
    '!dist/scripts/modernizr.js.map',
    '!dist/styles/editor-style.css',
    '!dist/styles/editor-style.css.map',
    '!dist/styles/main.css',
    '!dist/styles/main.css.map',
    '!gulpfile.js',
    '!node_modules',
    '!node_modules/**',
  ];
  // using base = '.' will transfer everything to /public_html correctly
  // turn off buffering in gulp.src for best performance
  return gulp.src( globs, { base: '.', buffer: false } )
    .pipe( conn.rmdir( '/domains/mydomain.com/public_html/web/app/themes/sage/dist' ), cb )
    .pipe( conn.newer( '/domains/mydomain.com/public_html/web/app/themes/sage' ) ) // only upload newer files
    .pipe( conn.dest( '/domains/mydomain.com/public_html/web/app/themes/sage' ) );
});

The remote folder is deleted, but I keep getting these errors which stops the uploading:

[10:55:13] 'upload' errored after 9.54 ms
[10:55:13] TypeError: Cannot read property 'on' of undefined
    at DestroyableTransform.Readable.pipe (/pathto/site/web/app/themes/sage/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:516:7)
    at Gulp.<anonymous> (/pathto/site/web/app/themes/sage/gulpfile.js:333:6)
    at module.exports (/pathto/site/web/app/themes/sage/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/pathto/site/web/app/themes/sage/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/pathto/site/web/app/themes/sage/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/pathto/site/web/app/themes/sage/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at runNextSet (/pathto/site/web/app/themes/sage/node_modules/run-sequence/index.js:79:16)
    at Gulp.onTaskEnd (/pathto/site/web/app/themes/sage/node_modules/run-sequence/index.js:68:5)
    at Gulp.emit (events.js:129:20)
    at Gulp.Orchestrator._emitTaskDone (/pathto/site/web/app/themes/sage/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
/pathto/site/web/app/themes/sage/node_modules/vinyl-ftp/lib/delete.js:53
                        cb( err );
                        ^
TypeError: undefined is not a function
    at final (/pathto/site/web/app/themes/sage/node_modules/vinyl-ftp/lib/delete.js:53:4)
    at /pathto/site/web/app/themes/sage/node_modules/vinyl-ftp/node_modules/ftp/lib/connection.js:739:21
    at Object.cb (/pathto/site/web/app/themes/sage/node_modules/vinyl-ftp/node_modules/ftp/lib/connection.js:503:13)
    at Parser.<anonymous> (/pathto/site/web/app/themes/sage/node_modules/vinyl-ftp/node_modules/ftp/lib/connection.js:113:22)
    at Parser.emit (events.js:110:17)
    at Parser._write (/pathto/site/web/app/themes/sage/node_modules/vinyl-ftp/node_modules/ftp/lib/parser.js:59:10)
    at doWrite (_stream_writable.js:301:12)
    at writeOrBuffer (_stream_writable.js:288:5)
    at Parser.Writable.write (_stream_writable.js:217:11)
    at Socket.ondata (/pathto/site/web/app/themes/sage/node_modules/vinyl-ftp/node_modules/ftp/lib/connection.js:273:20)

I tried to place a callback function cb() within the task, but that doesn't make a difference.
What am I doing wrong here? Any help is appreciated.
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.