<commit_before>var gulp = require('gulp');

var replace = require('gulp-replace');
var ts = require('gulp-typescript');
var concat = require('gulp-concat');
var jeditor = require("gulp-json-editor");
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');

var tsLib = ts.createProject({
    "declarationFiles": false,
    "noExternalResolve": true,
    "module": "commonjs",
});

var tsWeb = ts.createProject({
    "declarationFiles": false,
    "noExternalResolve": true,
    "sortOutput": true,
});

var src = {
    lib: ['lib/*.ts', 'tests/*.ts', '!lib/*-web.ts', '!lib/*.d.ts', 'typings/*/*.d.ts'],
    lib_web: ['lib/util-web.ts', 'lib/promise.ts', 'lib/util.ts', 'lib/charsets.ts', 'lib/fs-api.ts', 'lib/fs-misc.ts', 'lib/fs-glob.ts', 'lib/fs-sources.ts', 'lib/fs-targets.ts', 'lib/fs-plus.ts', 'lib/channel.ts', 'lib/channel-ws.ts', 'lib/sftp-enums.ts', 'lib/sftp-packet.ts', 'lib/sftp-misc.ts', 'lib/sftp-client.ts', 'lib/sftp.ts'],
    pkg: ['package.json'],
    npm: ['.npmignore', '../README.md', '../LICENSE'],
};

var out = {
    lib: '../build',
    lib_web: '../build/web',
};

gulp.task('lib', function () {

    var tsResult = gulp.src(src.lib).pipe(ts(tsLib));

    return tsResult.js
        .pipe(rename(function (path) {
            if (path.basename.substr(path.basename.length - 6) == "-tests")
                path.dirname = "./tests";
            else
                path.dirname = "./lib";
        }))
        .pipe(gulp.dest(out.lib));
});

gulp.task('web.ts', function () {

    return gulp.src(src.lib_web)
        .pipe(replace(/\r/g, ''))
        .pipe(replace(/import (.*) = require\(\"(.*)\"\);.*\n/g, ''))
        .pipe(replace(/import (.*) = (.*);.*\n/g, ''))
        .pipe(replace(/\/\/\/(.*).*\n/g, ''))
        .pipe(replace(/export const/g, 'const'))
        .pipe(replace(/export class/g, 'class'))
        .pipe(replace(/export interface/g, 'interface'))
        .pipe(replace(/export function/g, 'function'))
        .pipe(replace(/export .*=.*\n/g, ''))
        .pipe(replace(/new Buffer\(/g, 'new Uint8Array('))
        .pipe(replace(/NodeJS\./g, ''))
        .pipe(replace(/\n?.*\/\/ #if NODE(?:(?!#endif\b)[\s\S])*\/\/ #endif.*\n/g, ''))
        .pipe(replace(/^(\s*)(.*)WEB\: /gm, '$1'))
        .pipe(concat('sftp.ts'))
        .pipe(replace(/class Client /g, 'export class Client '))
        .pipe(replace(/^/g, 'module SFTP {'))
        .pipe(replace(/$/g, '\n}\n'))
        .pipe(replace(/\n/g, '\r\n'))
        .pipe(gulp.dest(out.lib_web));
});

gulp.task('web.js', ['web.ts'], function () {

    var mapOptions = {
        includeContent: false,
        sourceRoot: "./",
    };

    return gulp.src(out.lib_web + '/sftp.ts')
        .pipe(sourcemaps.init())
        .pipe(ts(tsWeb)).js
        .pipe(replace(/^(.*\n)*var SFTP;\n/g, '//\r\n//\r\n//\r\n//\r\n//\r\n\r\nvar SFTP;\r\n'))
        .pipe(sourcemaps.write(".", mapOptions))
        .pipe(gulp.dest(out.lib_web));

});

gulp.task('web', ['web.js'], function () {

    var uglifyOptions = {
        mangle: {
            except: ['SftpItem'],
            screw_ie8: true,
        },
        compress: {
            sequences: true,
            dead_code: true,
            conditionals: true,
            booleans: true,
            unused: true,
            if_return: true,
            join_vars: true,
            drop_console: true,
        },
        output: {
            preamble: "// http://github.com/lukaaash/sftp-ws/",
            //comments: "all",
            //beautify: true,
        }
    };

    return gulp.src(out.lib_web + '/sftp.js')
        .pipe(rename(function (path) { return path.basename = "sftp.min"; }))<commit_msg>Enhanced browser version regexes in the build script<commit_after>var gulp = require('gulp');

var replace = require('gulp-replace');
var ts = require('gulp-typescript');
var concat = require('gulp-concat');
var jeditor = require("gulp-json-editor");
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');

var tsLib = ts.createProject({
    "declarationFiles": false,
    "noExternalResolve": true,
    "module": "commonjs",
});

var tsWeb = ts.createProject({
    "declarationFiles": false,
    "noExternalResolve": true,
    "sortOutput": true,
});

var src = {
    lib: ['lib/*.ts', 'tests/*.ts', '!lib/*-web.ts', '!lib/*.d.ts', 'typings/*/*.d.ts'],
    lib_web: ['lib/util-web.ts', 'lib/promise.ts', 'lib/util.ts', 'lib/charsets.ts', 'lib/fs-api.ts', 'lib/fs-misc.ts', 'lib/fs-glob.ts', 'lib/fs-sources.ts', 'lib/fs-targets.ts', 'lib/fs-plus.ts', 'lib/channel.ts', 'lib/channel-ws.ts', 'lib/sftp-enums.ts', 'lib/sftp-packet.ts', 'lib/sftp-misc.ts', 'lib/sftp-client.ts', 'lib/sftp.ts'],
    pkg: ['package.json'],
    npm: ['.npmignore', '../README.md', '../LICENSE'],
};

var out = {
    lib: '../build',
    lib_web: '../build/web',
};

gulp.task('lib', function () {

    var tsResult = gulp.src(src.lib).pipe(ts(tsLib));

    return tsResult.js
        .pipe(rename(function (path) {
            if (path.basename.substr(path.basename.length - 6) == "-tests")
                path.dirname = "./tests";
            else
                path.dirname = "./lib";
        }))
        .pipe(gulp.dest(out.lib));
});

gulp.task('web.ts', function () {

    return gulp.src(src.lib_web)
        .pipe(replace(/\r/g, ''))
        .pipe(replace(/import (.*) = require\(\"(.*)\"\);.*\n/g, ''))
        .pipe(replace(/import (.*) = (.*);.*\n/g, ''))
        .pipe(replace(/\/\/\/(.*).*\n/g, ''))
        .pipe(replace(/export =\s*\S*\n/g, ''))
        .pipe(replace(/export (\S+\s)/g, '$1'))
        .pipe(replace(/new Buffer\(/g, 'new Uint8Array('))
        .pipe(replace(/NodeJS\./g, ''))
        .pipe(replace(/\n?.*\/\/ #if NODE(?:(?!#endif\b)[\s\S])*\/\/ #endif.*\n/g, ''))
        .pipe(replace(/^(\s*)(.*)WEB\: /gm, '$1'))
        .pipe(concat('sftp.ts'))
        .pipe(replace(/class Client /g, 'export class Client '))
        .pipe(replace(/^/g, 'module SFTP {'))
        .pipe(replace(/$/g, '\n}\n'))
        .pipe(replace(/\n/g, '\r\n'))
        .pipe(gulp.dest(out.lib_web));
});

gulp.task('web.js', ['web.ts'], function () {

    var mapOptions = {
        includeContent: false,
        sourceRoot: "./",
    };

    return gulp.src(out.lib_web + '/sftp.ts')
        .pipe(sourcemaps.init())
        .pipe(ts(tsWeb)).js
        .pipe(replace(/^var (.*\n){5}var SFTP;\n/g, '//\r\n//\r\n//\r\n//\r\n//\r\n' + 'var SFTP;\r\n'))
        .pipe(sourcemaps.write(".", mapOptions))
        .pipe(gulp.dest(out.lib_web));

});

gulp.task('web', ['web.js'], function () {

    var uglifyOptions = {
        mangle: {
            except: ['SftpItem'],
            screw_ie8: true,
        },
        compress: {
            sequences: true,
            dead_code: true,
            conditionals: true,
            booleans: true,
            unused: true,
            if_return: true,
            join_vars: true,
            drop_console: true,
        },
        output: {
            preamble: "// http://github.com/lukaaash/sftp-ws/",
            //comments: "all",
            //beautify: true,
        }
    };

    return gulp.src(out.lib_web + '/sftp.js')
        .pipe(rename(function (path) { return path.basename = "sftp.min"; }))
{'fraction_non_alphanumeric': 0.23853711790393012, 'fraction_numerical': 0.0013646288209606986, 'mean_word_length': 2.176853055916775, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, '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': '3573870', 'n_tokens_mistral': 2741, 'n_tokens_neox': 2690, 'n_words': 424}