<commit_before>'use strict'

let gulp = require('gulp')
let gutil = require('gulp-util')
let browserify = require('browserify')
let watchify = require('watchify')
let source = require('vinyl-source-stream')
let plugins = require('gulp-load-plugins')()
let browserSync = require('browser-sync').create()
let rimraf = require('rimraf')
let runSequence = require('run-sequence')
let babelify = require('babelify')

let reload = browserSync.reload

let paths = {
    vendor: {
        bootstrap: 'public/vendor/bootstrap'
    }
}

/**
 * Asset pipeline
 */
let bundleOptions = {
    entries: ['app/assets/javascripts/app.js'],
    debug: true
}

function bundleFile(file) {
    
    let bundler = watchify(browserify({
        entries: [`app/assets/javascripts/${file}.js`],
        debug: true
    }))
    
    bundler.transform(babelify)
    
    bundler.on('update', () => {
        gutil.log(`Bundling ${file}.js..`)
        bundle()
    })	

    return bundler.bundle()
        .on('error', gutil.log.bind(gutil, 'Browserify error'))
        .pipe(source(`${file}.js`))
        .pipe(gulp.dest('public/js'))
}

function bundle() {    
    let files = ['app']
    
    files.forEach(bundleFile)
}

gulp.task('bundle', bundle)

/**
 * Sass
 */

gulp.task('sass', () => 
    gulp.src('app/assets/stylesheets/*.scss')
        .pipe(plugins.sass().on('error', plugins.sass.logError))
        .pipe(gulp.dest('public/css'))
        .pipe(browserSync.stream())
)

gulp.task('sass:watch', () => 
    gulp.watch('app/assets/stylesheets/*.scss', ['sass']))
    
/**
 * BrowserSync
 */
gulp.task('browser-sync', () => {
    browserSync.init({
        proxy: 'localhost:3000',
        port: 3001,
        open: false,
        ui: {
            port: 3002
        }
    })
    
    gulp.watch('public/js/*.js', reload)
    gulp.watch('app/views/**/*.html.erb').on('change', reload)
})

/**
 * Standard build task
 * - copies bootstrap assets
 */
gulp.task('copy', () => {
    
    gulp.src('node_modules/bootstrap/dist/**/*.*')
        .pipe(gulp.dest(paths.vendor.bootstrap))
    
})

gulp.task('clean', (done) => {
    
    gutil.log('Removing bootstrap')
    rimraf(paths.vendor.bootstrap, {}, done)
    
})

gulp.task('build', ['copy'])
<commit_msg>Added gulp watch task for theme javascript files<commit_after>'use strict'

let gulp = require('gulp')
let gutil = require('gulp-util')
let browserify = require('browserify')
let watchify = require('watchify')
let source = require('vinyl-source-stream')
let plugins = require('gulp-load-plugins')()
let browserSync = require('browser-sync').create()
let rimraf = require('rimraf')
let runSequence = require('run-sequence')
let babelify = require('babelify')

let reload = browserSync.reload

let paths = {
    vendor: {
        bootstrap: 'public/vendor/bootstrap'
    }
}

/**
 * Asset pipeline
 */
let bundleOptions = {
    entries: ['app/assets/javascripts/app.js'],
    debug: true
}

function bundleFile(file) {
    
    let bundler = watchify(browserify({
        entries: [`app/assets/javascripts/${file}.js`],
        debug: true
    }))
    
    bundler.transform(babelify)
    
    bundler.on('update', () => {
        gutil.log(`Bundling ${file}.js..`)
        bundle()
    })	

    return bundler.bundle()
        .on('error', gutil.log.bind(gutil, 'Browserify error'))
        .pipe(source(`${file}.js`))
        .pipe(gulp.dest('public/js'))
}

function bundle() {    
    let files = ['app']
    
    files.forEach(bundleFile)
}

gulp.task('bundle', bundle)

/**
 * Sass
 */

gulp.task('sass', () => 
    gulp.src('app/assets/stylesheets/*.scss')
        .pipe(plugins.sass().on('error', plugins.sass.logError))
        .pipe(gulp.dest('public/css'))
        .pipe(browserSync.stream())
)

gulp.task('sass:watch', () => 
    gulp.watch('app/assets/stylesheets/*.scss', ['sass']))
    
/**
 * BrowserSync
 */
gulp.task('browser-sync', () => {
    browserSync.init({
        proxy: 'localhost:3000',
        port: 3001,
        open: false,
        ui: {
            port: 3002
        }
    })
    
    gulp.watch('public/js/*.js', reload)
    gulp.watch('public/theme/**/*.js', reload)
    
    gulp.watch('app/views/**/*.html.erb').on('change', reload)
})

/**
 * Standard build task
 * - copies bootstrap assets
 */
gulp.task('copy', () => {
    
    gulp.src('node_modules/bootstrap/dist/**/*.*')
        .pipe(gulp.dest(paths.vendor.bootstrap))
    
})

gulp.task('clean', (done) => {
    
    gutil.log('Removing bootstrap')
    rimraf(paths.vendor.bootstrap, {}, done)
    
})

gulp.task('build', ['copy'])

{'fraction_non_alphanumeric': 0.19150798861895382, 'fraction_numerical': 0.005252790544977019, 'mean_word_length': 2.7706270627062706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1395479', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1541, 'n_words': 251}