<commit_before>/**
 * Transmits project files / .zip package to remote server via ftp
 * Dependencies:
 * - vinyl-ftp
 * - gulp-prompt
 * - run-sequence
 * - del
 */

var gulp = require('gulp');
var gutil = require('gulp-util');
var ftp = require('vinyl-ftp');
var prompt = require('gulp-prompt');
var runSequence = require('run-sequence');
var config = require('../../config').ftp;
var credentials = require('../../credentials').ftp;
var del = require('del');

var ftpConn;

gulp.task('ftp', function() {
    return gulp.src('').pipe(
        prompt.prompt({
            type: 'checkbox',
            name: 'zip_upload',
            message: 'Upload entire directory in .zip format? If no, only modified files will be uploaded',
            choices: ['yes', 'no']
        }, function(result) {
            ftpConn = createFTPConnection();
            var choice = result.zip_upload[0];

            if (choice === 'no') {
                return gulp.src(config.src, { base:config.base, buffer:false })
                    .pipe(ftpConn.newer(credentials.directory))
                    .pipe(ftpConn.dest(credentials.directory));
            } else if (choice === 'yes') {
                runSequence('zip', 'upload', function() {
                    del(['./' + global.zipFileName]);
                });
            }
        })
    );
});

gulp.task('upload', function() {
    ftpConn = ftpConn || createFTPConnection();

    return gulp.src('./' + global.zipFileName, { base:'.', buffer:false })
        .pipe(ftpConn.dest(credentials.directory));
});

function createFTPConnection() {
    var ftpOptions = {
        host: credentials.host,
        user: credentials.username,
        password: <PASSWORD>,
        log: gutil.log
    };

    // merge ftp credentials with ftp config options
    Object.keys(config.options).forEach(function(key) { ftpOptions[key] = config.options[key]; });
    return ftp.create(ftpOptions);
}<commit_msg>Modified ftp task for Windows OS<commit_after>/**
 * Transmits project files / .zip package to remote server via ftp
 * Dependencies:
 * - vinyl-ftp
 * - gulp-prompt
 * - run-sequence
 * - del
 */

var gulp = require('gulp');
var gutil = require('gulp-util');
var ftp = require('vinyl-ftp');
var prompt = require('gulp-prompt');
var runSequence = require('run-sequence');
var config = require('../../config').ftp;
var credentials = require('../../credentials').ftp;
var del = require('del');

var ftpConn;

gulp.task('ftp', function(callback) {
    var isWin = /^win/.test(process.platform);

    // Windows does not work well with gulp-prompt it seems. So on Windows, we skip the prompt altogther and upload a zip file.
    if (isWin) {
        runSequence.apply(null, [].concat(sequenceTasks, function() {
            del(['./' + global.zipFileName]);
        }));
    } else {
        return gulp.src('').pipe(
            prompt.prompt({
                type: 'checkbox',
                name: 'zip_upload',
                message: 'Upload entire directory in .zip format? If no, only modified files will be uploaded',
                choices: ['yes', 'no']
            }, function(result) {
                ftpConn = createFTPConnection();
                var choice = result.zip_upload[0];

                if (choice === 'no') {
                    return gulp.src(config.src, { base:config.base, buffer:false })
                        .pipe(ftpConn.newer(credentials.directory))
                        .pipe(ftpConn.dest(credentials.directory));
                } else if (choice === 'yes') {
                    runSequence.apply(null, [].concat(sequenceTasks, function() {
                        del(['./' + global.zipFileName]);
                    }));
                }
            })
        );
    }
});

gulp.task('upload', function() {
    ftpConn = ftpConn || createFTPConnection();

    return gulp.src('./' + global.zipFileName, { base:'.', buffer:false })
        .pipe(ftpConn.dest(credentials.directory));
});

function createFTPConnection() {
    var ftpOptions = {
        host: credentials.host,
        user: credentials.username,
        password: <PASSWORD>,
        log: gutil.log
    };

    // merge ftp credentials with ftp config options
    Object.keys(config.options).forEach(function(key) { ftpOptions[key] = config.options[key]; });
    return ftp.create(ftpOptions);
}
{'fraction_non_alphanumeric': 0.15322765908568803, 'fraction_numerical': 0.00045945325063174823, 'mean_word_length': 2.22279792746114, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4598217', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1212, 'n_words': 294}