vinyl-ftp
vinyl-ftp copied to clipboard
Clean process not clear
Could you do simple examples for it? In './test' I see only complex and "kill my self-appraisal" example - after analyzing this code I have lot of small questions (for example: "vftp" - not declared) and finally I don't understand it. Other words I kindly ask you improve description documentation. This is not work:
gulp.task( 'ftp-clean', function () {
return gulp.clean( 'dist/**', 'test/' );
} );
-
var conn = ftp.create( config )
- OK, I got src - all workable here for me
var globs = [
'dist/**/*'
];
-
conn.clean( globs, local[, options] )
- not clear how understand and use it. (and whylocal[,
and notlocal, [
orlocal[options],
) a)gulp.clean( 'dist/**', 'test/' )
- not work (it's according examplesuite.vftp.clean( 'test/clean/**', 'test/fixtures' )
) b)gulp.clean( globs, 'dist/**' )
- not work c)gulp.clean( globs, { base: './dist', buffer: false } )
- not work
You should return the stream created by clean
:
gulp.task(
'ftp-clean',
function () {
var conn = ftp.create( ftpOptions );
return conn.clean( globs, local, { base: '.' } );
}
);
Although in docs options
parameter is said to be optional, vinyl-ftp
asks for a base
every time I try to omit it.
I seriously don't understand this either. It would be great to have a simple example in the docs ^^
+1 on this, I tried to use clean
on my pipeline and got errors.
I finally got it right, here's what I did (I simplified the code for the example) :
/*
- the first parameter is the remote path to clean; the '/**' at the end is really important, it matches all the files to verify before cleaning
- the second parameter is the local path, usually the current working directory
- the third parameter is redundant but needed; it's the remote path, but without the '/**'
*/
ftp.create(..).clean('public/**', '.', {base: 'public'});
I also experimented with this method, did not working.
I always get this error: Error: Prohibited directory name
Since I got a lot of struggle with this, here a working peace of code. It removes all files from the server that dont exist locally except the usage
folder:
var connection = ftp.create({ ... });
connection.clean([
'/*.*',
'/!(usage)*',
'/de/**',
'/en/**',
'/images/**',
'/fonts/**',
'/json/**',
'/sounds/**'
], './dist', { base: '/' });
My files are locally on the ./dist
folder and remote directly in the root directory (/
) (of the used ftp user).
I also get the prohibited file name error.
Here is the Command:
gulp.task('clean', function() {
var conn = ftp.create();
return conn.clean('public_html/**', '.', {base: 'public_html'});
});
And here is the error:
Error: Prohibited file name: \public_html\source\localtest.php
Any ideas?