<commit_before>'use strict';

//====================================================================

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

//====================================================================

var options = require('minimist')(process.argv, {
  boolean: ['production'],

  default: {
    production: false,
  }
});

//====================================================================

var DIST_DIR = __dirname +'/dist';
var SRC_DIR = __dirname +'/app';
var BOWER_DIR = (function () {
  var cfg;

  try
  {
    cfg = JSON.parse(require('fs').readFileSync('./.bowerrc'));
  }
  catch (error)
  {
    cfg = {};
  }

  cfg.cwd || (cfg.cwd = __dirname);
  cfg.directory || (cfg.directory = 'bower_components');

  return cfg.cwd +'/'+ cfg.directory;
})();

var PRODUCTION = options.production;
var LIVERELOAD = 46417;

//--------------------------------------------------------------------

var combine = function () {
  combine = require('stream-combiner');
  return combine.apply(this, arguments);
};

var concat = function () {
  concat = require('event-stream').concat;
  return concat.apply(this, arguments);
};

var gIf = function () {
  gIf = $.if;
  return gIf.apply(this, arguments);
};

var src = (function () {
  if (PRODUCTION)
  {
    return function (pattern) {
      return gulp.src(SRC_DIR +'/'+ pattern, {
        base: SRC_DIR,
      });
    };
  }

  // gulp-plumber prevents streams from disconnecting when errors.
  // See: https://gist.github.com/floatdrop/8269868#file-thoughts-md
  return function (pattern) {
    return $.watch({
      glob: SRC_DIR +'/'+ pattern,
      base: SRC_DIR,
    }).pipe($.plumber({
      errorHandler: console.error,
    }));
  };
})();

var dest = (function () {
  if (PRODUCTION)
  {
    return function () {
      return gulp.dest(DIST_DIR);
    };
  }

  return function () {
    return combine(
      gulp.dest(DIST_DIR),
      $.livereload(LIVERELOAD)
    );
  };
})();

//====================================================================

gulp.task('build-pages', function () {
  // TODO: Add minification (gulp-htmlmin).
  return concat(
    src('index.html').pipe(
      gIf(!PRODUCTION, $.embedlr({
        port: LIVERELOAD,
      }))
    ),
    src('views/**/*.jade').pipe($.jade()),
    src('views/**/*.html')
  ).pipe(
    dest()
  );
});

gulp.task('build-scripts', function () {
  return concat(
    src('scripts/**/*.coffee').pipe($.coffee()),
    src('scripts/**/*.js')
  ).pipe(
    gIf(PRODUCTION, combine(
      $.ngmin(),
      $.uglify()
    ))
  ).pipe(
    dest()
  );
});

gulp.task('build-styles', ['install-bower-components'], function () {
  return src('styles/main.sass').pipe(
    $.rubySass({
      loadPath: [
        BOWER_DIR,

        // Bug in gulp-ruby-sass, local directory should be in the
        // include path.
        SRC_DIR +'/styles'
      ]
    })<commit_msg>Do not compile Jade files starting with an underscore.<commit_after>'use strict';

//====================================================================

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

//====================================================================

var options = require('minimist')(process.argv, {
  boolean: ['production'],

  default: {
    production: false,
  }
});

//====================================================================

var DIST_DIR = __dirname +'/dist';
var SRC_DIR = __dirname +'/app';
var BOWER_DIR = (function () {
  var cfg;

  try
  {
    cfg = JSON.parse(require('fs').readFileSync('./.bowerrc'));
  }
  catch (error)
  {
    cfg = {};
  }

  cfg.cwd || (cfg.cwd = __dirname);
  cfg.directory || (cfg.directory = 'bower_components');

  return cfg.cwd +'/'+ cfg.directory;
})();

var PRODUCTION = options.production;
var LIVERELOAD = 46417;

//--------------------------------------------------------------------

var pipe = function () {
  pipe = require('event-stream').pipe;
  return pipe.apply(this, arguments);
};

var concat = function () {
  concat = require('event-stream').concat;
  return concat.apply(this, arguments);
};

var gIf = function () {
  gIf = $.if;
  return gIf.apply(this, arguments);
};

var src = (function () {
  if (PRODUCTION)
  {
    return function (pattern) {
      return gulp.src(pattern, {
        base: SRC_DIR,
        cwd: SRC_DIR,
      });
    };
  }

  // gulp-plumber prevents streams from disconnecting when errors.
  // See: https://gist.github.com/floatdrop/8269868#file-thoughts-md
  return function (pattern) {
    return gulp.src(pattern, {
      base: SRC_DIR,
      cwd: SRC_DIR,
    }).pipe(
      $.watch()
    ).pipe(
      $.plumber({
        errorHandler: console.error,
      })
    );
  };
})();

var dest = (function () {
  if (PRODUCTION)
  {
    return function () {
      return gulp.dest(DIST_DIR);
    };
  }

  return function () {
    return pipe(
      gulp.dest(DIST_DIR),
      $.livereload(LIVERELOAD)
    );
  };
})();

//====================================================================

gulp.task('build-pages', function () {
  // TODO: Add minification (gulp-htmlmin).
  return concat(
    src('index.html').pipe(
      gIf(!PRODUCTION, $.embedlr({
        port: LIVERELOAD,
      }))
    ),
    src(['views/**/*.jade', '!**/_*']).pipe($.jade()),
    src('views/**/*.html')
  ).pipe(
    dest()
  );
});

gulp.task('build-scripts', function () {
  return concat(
    src('scripts/**/*.coffee').pipe($.coffee()),
    src('scripts/**/*.js')
  ).pipe(
    gIf(PRODUCTION, pipe(
      $.ngmin(),
      $.uglify()
    ))
  ).pipe(
    dest()
  );
});

gulp.task('build-styles', ['install-bower-components'], function () {
  return src('styles/main.sass').pipe(
    $.rubySass({
      loadPath: [
        BOWER_DIR,

        // Bug in gulp-ruby-sass, local directory should be in the
        // include path.
        SRC_DIR +'/styles'
      ]
    })
{'fraction_non_alphanumeric': 0.28549669994923, 'fraction_numerical': 0.004061600947706888, 'mean_word_length': 2.689138576779026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6106917', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1871, 'n_words': 360}