<commit_before>gulp = require('gulp')
watch = require('gulp-watch')
source = require('vinyl-source-stream')
buffer = require('vinyl-buffer')
util = require('gulp-util')
plumber = require('gulp-plumber')
sourcemaps = require('gulp-sourcemaps')
extend = require('xtend')
_ = require('lodash')

refresh = require('gulp-livereload')
lrServer = require('tiny-lr')()

# default environment to development
process.env.NODE_ENV or= 'development'

env = process.env
nodeEnv = env.NODE_ENV

lr = undefined
errorHandler = (err) ->
  util.beep()
  util.log(util.colors.red(err))

#
# styles
#
sass = require('gulp-sass')
autoprefix = require('gulp-autoprefixer')
rename = require('gulp-rename')
filter = require('gulp-filter')

sassPaths =  [
  "node_modules/bootstrap-sass/assets/stylesheets/"
  "node_modules/font-awesome/scss/"
  "node_modules/angular-xeditable/dist/css"
]

styles = ->

  entryFilter = filter (file) ->
    /src\/[^\/]+\.(sass|scss)$/.test(file.path)

  srcPaths = ['src/**/']
    .concat(sassPaths)
    .map (path) -> path + "*.{sass,scss}"

  gulp.src(srcPaths)
    .pipe(plumber(
      errorHandler: (err) ->
        errorHandler(err)
        # https://github.com/floatdrop/gulp-plumber/issues/8
        this.emit('end')
    ))
    .pipe(sourcemaps.init())
    .pipe(entryFilter)
    .pipe(sass(
      includePaths: sassPaths
    ))
    .pipe(sourcemaps.write(includeContent: false))
    .pipe(sourcemaps.init(loadMaps: true))
    .pipe(autoprefix(
      browsers: ['> 1%', 'last 2 versions']
    ))
    .pipe(sourcemaps.write('../maps', sourceRoot: '../styles/'))
    .pipe(gulp.dest('build/styles'))
    .pipe(if lr then require('gulp-livereload')(lr) else util.noop())

gulp.task 'styles-build', styles
gulp.task 'styles-watch', ['styles-build'], ->
  gulp.watch('src/**/*.sass', ['styles-build'])

#
# scripts
#
browserify = require('browserify')
mold = require('mold-source-map')

scripts = (isWatch) ->
  ->
    plugin = (bundler) ->
      bundler
        .plugin(require('bundle-collapser/plugin'))

    bundle = (bundler) ->
      bundler.bundle()
        .on('error', util.log.bind(util, "browserify error"))
        .pipe(plumber({ errorHandler }))
        .pipe(mold.transformSourcesRelativeTo('./src'))
        .pipe(source('index.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init(loadMaps: true))
        .pipe(if nodeEnv == 'production' then require('gulp-uglify')() else util.noop())
        .pipe(sourcemaps.write('../maps'))
        .pipe(gulp.dest('build/scripts'))
        .pipe(if lr then require('gulp-livereload')(lr) else util.noop())

    args = {
      entries: ['.']
      debug: true
    }

    if (isWatch)
      watchify = require('watchify')
      bundler = watchify(browserify(extend(args, watchify.args)))
      rebundle = -> bundle(bundler)<commit_msg>uglify on production or staging<commit_after>gulp = require('gulp')
watch = require('gulp-watch')
source = require('vinyl-source-stream')
buffer = require('vinyl-buffer')
util = require('gulp-util')
plumber = require('gulp-plumber')
sourcemaps = require('gulp-sourcemaps')
extend = require('xtend')
_ = require('lodash')

refresh = require('gulp-livereload')
lrServer = require('tiny-lr')()

# default environment to development
process.env.NODE_ENV or= 'development'

env = process.env
nodeEnv = env.NODE_ENV

isDeploy = (env) ->
  env == "production" or env == "staging"

lr = undefined
errorHandler = (err) ->
  util.beep()
  util.log(util.colors.red(err))

#
# styles
#
sass = require('gulp-sass')
autoprefix = require('gulp-autoprefixer')
rename = require('gulp-rename')
filter = require('gulp-filter')

sassPaths =  [
  "node_modules/bootstrap-sass/assets/stylesheets/"
  "node_modules/font-awesome/scss/"
  "node_modules/angular-xeditable/dist/css"
]

styles = ->

  entryFilter = filter (file) ->
    /src\/[^\/]+\.(sass|scss)$/.test(file.path)

  srcPaths = ['src/**/']
    .concat(sassPaths)
    .map (path) -> path + "*.{sass,scss}"

  gulp.src(srcPaths)
    .pipe(plumber(
      errorHandler: (err) ->
        errorHandler(err)
        # https://github.com/floatdrop/gulp-plumber/issues/8
        this.emit('end')
    ))
    .pipe(sourcemaps.init())
    .pipe(entryFilter)
    .pipe(sass(
      includePaths: sassPaths
    ))
    .pipe(sourcemaps.write(includeContent: false))
    .pipe(sourcemaps.init(loadMaps: true))
    .pipe(autoprefix(
      browsers: ['> 1%', 'last 2 versions']
    ))
    .pipe(sourcemaps.write('../maps', sourceRoot: '../styles/'))
    .pipe(gulp.dest('build/styles'))
    .pipe(if lr then require('gulp-livereload')(lr) else util.noop())

gulp.task 'styles-build', styles
gulp.task 'styles-watch', ['styles-build'], ->
  gulp.watch('src/**/*.sass', ['styles-build'])

#
# scripts
#
browserify = require('browserify')
mold = require('mold-source-map')

scripts = (isWatch) ->
  ->
    plugin = (bundler) ->
      bundler
        .plugin(require('bundle-collapser/plugin'))

    bundle = (bundler) ->
      bundler.bundle()
        .on('error', util.log.bind(util, "browserify error"))
        .pipe(plumber({ errorHandler }))
        .pipe(mold.transformSourcesRelativeTo('./src'))
        .pipe(source('index.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init(loadMaps: true))
        .pipe(if isDeploy(nodeEnv) then require('gulp-uglify')() else util.noop())
        .pipe(sourcemaps.write('../maps'))
        .pipe(gulp.dest('build/scripts'))
        .pipe(if lr then require('gulp-livereload')(lr) else util.noop())

    args = {
      entries: ['.']
      debug: true
    }

    if (isWatch)
      watchify = require('watchify')
      bundler = watchify(browserify(extend(args, watchify.args)))
      rebundle = -> bundle(bundler)
{'fraction_non_alphanumeric': 0.18544559676568817, 'fraction_numerical': 0.001054666901037089, 'mean_word_length': 3.3040847201210286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 2, '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': '1250745', 'n_tokens_mistral': 1995, 'n_tokens_neox': 1966, 'n_words': 321}