morris / vinyl-ftp

Blazing fast vinyl adapter for FTP
Other
388 stars 31 forks source link

remote folder gets completely synced with the local folder (delete old files, update/upload/change new files) #91

Open Mojo90 opened 7 years ago

Mojo90 commented 7 years ago

I have a project folder where on local the script I use is in /deploy/ftp_upload.gulp.js and the remote files are in /. So to upload the newest files is not the problem. But I also want to delete the files on the remote, which are already deleted locally. So the clean function seems perfect. But I already saw in googling and other issues that there are some issues here. So I tried a few things, e.g.:

gulp.task('ftp-clean', ["ftp-upload"], function() {
  var conn = getFtpConnection();
  return conn.clean("/**/*", dataFolder);
});

where dataFolder is the local root folder of the files. But than it throws an error with: throw new Error('base must be a non-empty string, or null/undefined.'); --> as I understand from the docs options and thus base is optional, so sorry to say that but very bad docs. I also tried different options for base here, e.g.: /, ., ../, /**/* etc. But nothing helped. Sometimes it crashed with an error and sometimes my remote folder was empty afterwards.

So can somebody pls share the simplest minimal example, where the remote folder gets completely synced with the local folder (delete old files, update/upload/change new files). That would be great and I think that this will help a lot of people!

Thank you!

j0an commented 7 years ago

Ineed something like this issue, just conn.sync

djibarian commented 7 years ago

Docs are not clear about the usage. Try this:

return conn.clean(
    path.join(remoteRoot, '**'),
    localRoot,
    { base: remoteRoot }
);