Recursively delete non-empty nested directories with jsftp, like 'rm -r'
FTP can natively delete only one directory at the time and it must be empty.
Useful for being able to clean up remote directories before uploading files.
$ npm install --save jsftp-rmr
var jsFtp = require('jsftp');
// decorate `jsFtp` with a new method `rmr`
jsFtp = require('jsftp-rmr')(jsFtp);
var remoteDirectory = 'public_html/deploy'
ftp = new jsFtp(options);
ftp.rmr(remoteDirectory, function (err) {
console.log('Successfully removed:', remoteDirectory);
});
Required
Type: string
Path of the remote directory to recursively remove.
Using this command in production can be dangerous. Use it at your own risk.
MIT © Alberto Mijares