<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

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/font-awesome/scss/"
]

styles = ->

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

  srcPaths = ['app/**/']
    .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('app/**/*.sass', ['styles-build'])

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

scripts = (isWatch) ->
  ->
    plugin = (bundler) ->
      bundler
        .plugin(require('bundle-collapser/plugin'))<commit_msg>gulp-watch scss in component directories<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/font-awesome/scss/"
]

styles = ->

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

  srcPaths = ['app/**/']
    .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('app/**/*.sass', ['styles-build'])
  gulp.watch('app/components/**/*.scss', ['styles-build'])

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

scripts = (isWatch) ->
  ->
    plugin = (bundler) ->
      bundler
        .plugin(require('bundle-collapser/plugin'))
{'fraction_non_alphanumeric': 0.19249632172633643, 'fraction_numerical': 0.0014713094654242277, 'mean_word_length': 3.645785876993166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2044031', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1455, 'n_words': 243}