vinyl-ftp icon indicating copy to clipboard operation
vinyl-ftp copied to clipboard

Clean process not clear

Open VitaliyAT opened this issue 8 years ago • 8 comments

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/' );
} );
  1. var conn = ftp.create( config ) - OK, I got src - all workable here for me
var globs = [
    'dist/**/*'
];

  1. conn.clean( globs, local[, options] ) - not clear how understand and use it. (and why local[, and not local, [ or local[options],) a) gulp.clean( 'dist/**', 'test/' ) - not work (it's according example suite.vftp.clean( 'test/clean/**', 'test/fixtures' ) ) b) gulp.clean( globs, 'dist/**' ) - not work c) gulp.clean( globs, { base: './dist', buffer: false } ) - not work

VitaliyAT avatar Aug 07 '16 13:08 VitaliyAT

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.

kapooostin avatar Aug 13 '16 20:08 kapooostin

I seriously don't understand this either. It would be great to have a simple example in the docs ^^

pyrsmk avatar Oct 12 '16 17:10 pyrsmk

+1 on this, I tried to use clean on my pipeline and got errors.

TCB13 avatar Oct 18 '16 22:10 TCB13

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'});

pyrsmk avatar Oct 19 '16 08:10 pyrsmk

I also experimented with this method, did not working.

grig0ry avatar Nov 25 '16 08:11 grig0ry

I always get this error: Error: Prohibited directory name

Alipio123 avatar Mar 27 '17 15:03 Alipio123

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).

blaues0cke avatar Sep 12 '17 14:09 blaues0cke

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?

JordashTalon avatar Jan 17 '18 02:01 JordashTalon