<commit_before>var path = require('path');
var del = require('del');

/* font compress npm module */
var rename = require('gulp-rename');
var gfi = require("gulp-file-insert");
var fontSpider = require('gulp-font-spider');
var gulpCopy = require('gulp-copy');
/****************************/

var bower = require('./bower.json');
var bowerDir = 'vendor';

var gulp = require('gulp');
var plugins = require("gulp-load-plugins")({
    pattern: ['gulp-*', 'gulp.*', 'main-bower-files'],
    replaceString: /\bgulp[\-.]/,
    rename: {
        "gulp-minify-css": "minifyCSS",
        "gulp-css-url-basename": "basename"
    }
});
var runSequence = require('run-sequence');

// script
var SCRIPT = 'template/*.js';
var CSS = 'template/*.css';

var DEBUG = 'build';
var RELEASE = 'bin';

gulp.task('debug', ['build_index']);
gulp.task('release', ['bin_index']);

gulp.task('debug', function (callback) {
    runSequence('clean',
        ['build_js', 'build_css', 'build_copy'],
        'build_index',
        'build_copy_custom',
        callback);
});

gulp.task('release', function (callback) {
    runSequence('clean',
        ['bin_js', 'bin_css', 'bin_copy'],
        'bin_index',
        'bin_copy_custom',
        callback);
});

gulp.task('clean', function () {
    del.sync([DEBUG, RELEASE]);
});

gulp.task('build_js', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: '**/*.js'
    }))
        //.pipe(plugins.debug())
        .pipe(plugins.concat(bowerDir + bower.version + '.js'))
        .pipe(gulp.dest(DEBUG))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('bin_js', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: '**/*.js'
    }))
        //.pipe(plugins.debug())
        .pipe(plugins.concat(bowerDir + bower.version + '.js'))
        .pipe(plugins.uglify())
        .pipe(gulp.dest(RELEASE))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('build_css', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: '**/*.css'
    }))
        .pipe(plugins.concat(bowerDir + bower.version + '.min.css'))
        .pipe(plugins.basename())
        .pipe(gulp.dest(DEBUG))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('bin_css', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: '**/*.css'
    }))
        .pipe(plugins.concat(bowerDir + bower.version + '.min.css'))
        .pipe(plugins.basename())
        .pipe(plugins.minifyCSS())
        .pipe(gulp.dest(RELEASE))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('build_copy', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: /.*\.((?!less|css|js).)*$/i
    }).concat('assets/*').concat('out/*.html'))
        .pipe(gulp.dest(DEBUG))
        .on('error', plugins.util.log);
});

gulp.task('bin_copy', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: /.*\.((?!less|css|js).)*$/i
    }).concat('assets/*').concat('out/*.html'))
        .pipe(gulp.dest(RELEASE))
        .on('error', plugins.util.log);
});

gulp.task('build_copy_custom', function () {
    return gulp.src(['template/custom/*.js', 'template/custom/*.css'])
        .pipe(gulp.dest(DEBUG))
        .on('error', plugins.util.log);
});

gulp.task('bin_copy_custom', function () {
    return gulp.src(['template/*/*.js', 'template/*/*.css'])
        .pipe(gulp.dest(RELEASE))
        .on('error', plugins.util.log);
});

gulp.task('build_index', ['build_copy', 'build_css', 'build_js'], function () {
    var target = DEBUG + '/*.html';
    var sources = gulp.src([DEBUG + '/*.js', DEBUG + '/*.css'], {read: false});
    return gulp.src(target)
        .pipe(plugins.inject(sources, {relative: true}))
        .pipe(gulp.dest(DEBUG))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('bin_index', ['bin_copy', 'bin_css', 'bin_js'], function () {
    var target = RELEASE + '/*.html';
    var sources = gulp.src([RELEASE + '/*.js', RELEASE + '/*.css'], {read: false});
    return gulp.src(target)
        .pipe(plugins.inject(sources, {relative: true}))
        .pipe(gulp.dest(RELEASE))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});


/* font compress tasks */
gulp.task('font-compress', ['renameFontName', 'insertJadeToHtml'], function () {
    return gulp.src('font-compress/template/fontCompressTemplate.html')
        .pipe(fontSpider());
});

gulp.task('renameFontName', function () {
    gulp.src('font-compress/FZLanTYJW_Zhun.eot')
        .pipe(rename('FZLanTYJWC.eot'))
        .pipe(gulp.dest('assets/'));
    return gulp.src('font-compress/FZLanTYJW_Zhun.ttf')
        .pipe(rename('FZLanTYJWC.ttf'))
        .pipe(gulp.dest('assets/'));
});

gulp.task('renameJadeConcatedTemplate', function () {
    return gulp.src('font-compress/fontCompressTemplate.html')
        .pipe(rename('fontCompressTemplate.html'))
        .pipe(gulp.dest('font-compress/template/'));
});

gulp.task('insertJadeToHtml', ['renameJadeConcatedTemplate'], function () {
    return gulp.src('font-compress/template/fontCompressTemplate.html')
        .pipe(gfi({
            "/* jadeStr */": "font-compress/template/seed1.jade"
        }))
        .pipe(gulp.dest('font-compress/template/'))
});

//优先npm start
gulp.task('copy-seed1', function () {
    return gulp.src('template/videoSharing/sharePage.jade')
        .pipe(gulpCopy('font-compress/', 3));
});
/********************/<commit_msg>[ronfe] fix font compress bug<commit_after>var path = require('path');
var del = require('del');

/* font compress npm module */
var rename = require('gulp-rename');
var gfi = require("gulp-file-insert");
var fontSpider = require('gulp-font-spider');
var gulpCopy = require('gulp-copy');
/****************************/

var bower = require('./bower.json');
var bowerDir = 'vendor';

var gulp = require('gulp');
var plugins = require("gulp-load-plugins")({
    pattern: ['gulp-*', 'gulp.*', 'main-bower-files'],
    replaceString: /\bgulp[\-.]/,
    rename: {
        "gulp-minify-css": "minifyCSS",
        "gulp-css-url-basename": "basename"
    }
});
var runSequence = require('run-sequence');

// script
var SCRIPT = 'template/*.js';
var CSS = 'template/*.css';

var DEBUG = 'build';
var RELEASE = 'bin';

gulp.task('debug', ['build_index']);
gulp.task('release', ['bin_index']);

gulp.task('debug', function (callback) {
    runSequence('clean',
        ['build_js', 'build_css', 'build_copy'],
        'build_index',
        'build_copy_custom',
        callback);
});

gulp.task('release', function (callback) {
    runSequence('clean',
        ['bin_js', 'bin_css', 'bin_copy'],
        'bin_index',
        'bin_copy_custom',
        callback);
});

gulp.task('clean', function () {
    del.sync([DEBUG, RELEASE]);
});

gulp.task('build_js', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: '**/*.js'
    }))
        //.pipe(plugins.debug())
        .pipe(plugins.concat(bowerDir + bower.version + '.js'))
        .pipe(gulp.dest(DEBUG))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('bin_js', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: '**/*.js'
    }))
        //.pipe(plugins.debug())
        .pipe(plugins.concat(bowerDir + bower.version + '.js'))
        .pipe(plugins.uglify())
        .pipe(gulp.dest(RELEASE))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('build_css', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: '**/*.css'
    }))
        .pipe(plugins.concat(bowerDir + bower.version + '.min.css'))
        .pipe(plugins.basename())
        .pipe(gulp.dest(DEBUG))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('bin_css', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: '**/*.css'
    }))
        .pipe(plugins.concat(bowerDir + bower.version + '.min.css'))
        .pipe(plugins.basename())
        .pipe(plugins.minifyCSS())
        .pipe(gulp.dest(RELEASE))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('build_copy', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: /.*\.((?!less|css|js).)*$/i
    }).concat('assets/*').concat('out/*.html'))
        .pipe(gulp.dest(DEBUG))
        .on('error', plugins.util.log);
});

gulp.task('bin_copy', function () {
    return gulp.src(plugins.mainBowerFiles({
        base: bowerDir,
        filter: /.*\.((?!less|css|js).)*$/i
    }).concat('assets/*').concat('out/*.html'))
        .pipe(gulp.dest(RELEASE))
        .on('error', plugins.util.log);
});

gulp.task('build_copy_custom', function () {
    return gulp.src(['template/custom/*.js', 'template/custom/*.css'])
        .pipe(gulp.dest(DEBUG))
        .on('error', plugins.util.log);
});

gulp.task('bin_copy_custom', function () {
    return gulp.src(['template/*/*.js', 'template/*/*.css'])
        .pipe(gulp.dest(RELEASE))
        .on('error', plugins.util.log);
});

gulp.task('build_index', ['build_copy', 'build_css', 'build_js'], function () {
    var target = DEBUG + '/*.html';
    var sources = gulp.src([DEBUG + '/*.js', DEBUG + '/*.css'], {read: false});
    return gulp.src(target)
        .pipe(plugins.inject(sources, {relative: true}))
        .pipe(gulp.dest(DEBUG))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});

gulp.task('bin_index', ['bin_copy', 'bin_css', 'bin_js'], function () {
    var target = RELEASE + '/*.html';
    var sources = gulp.src([RELEASE + '/*.js', RELEASE + '/*.css'], {read: false});
    return gulp.src(target)
        .pipe(plugins.inject(sources, {relative: true}))
        .pipe(gulp.dest(RELEASE))
        .pipe(plugins.filesize())
        .on('error', plugins.util.log);
});


/* font compress tasks */
gulp.task('font-compress', ['renameFontName', 'insertJadeToHtml'], function () {
    return gulp.src('font-compress/template/fontCompressTemplate.html')
        .pipe(fontSpider());
});

gulp.task('renameFontName', function () {
    gulp.src('font-compress/FZLanTYJW_Zhun.eot')
        .pipe(rename('FZLanTYJWC.eot'))
        .pipe(gulp.dest('assets/'));
    return gulp.src('font-compress/FZLanTYJW_Zhun.ttf')
        .pipe(rename('FZLanTYJWC.ttf'))
        .pipe(gulp.dest('assets/'));
});

gulp.task('renameJadeConcatedTemplate', function () {
    return gulp.src('font-compress/fontCompressTemplate.html')
        .pipe(rename('fontCompressTemplate.html'))
        .pipe(gulp.dest('font-compress/template/'));
});

gulp.task('insertJadeToHtml', ['renameJadeConcatedTemplate'], function () {
    return gulp.src('font-compress/template/fontCompressTemplate.html')
        .pipe(gfi({
            "/* jadeStr */": "font-compress/template/videoSharing/sharePage.jade"
        }))
        .pipe(gulp.dest('font-compress/template/'))
});

//优先npm start
gulp.task('copy-seed1', function () {
    return gulp.src('template/videoSharing/sharePage.jade')
        .pipe(gulpCopy('font-compress/', 3));
});
/********************/
{'fraction_non_alphanumeric': 0.21650561504309218, 'fraction_numerical': 0.00043527465830939325, 'mean_word_length': 3.0252277505255782, 'pattern_counts': {'":': 6, '<': 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': '1939556', 'n_tokens_mistral': 3972, 'n_tokens_neox': 3942, 'n_words': 582}