<commit_before>// Require the needed packages
var browserify   = require('browserify'),
    buffer       = require('vinyl-buffer'),
    coffeeify    = require('coffeeify'),
    hbsfy        = require('hbsfy').configure({extensions: ['.hbs']}),
    del          = require('del'),
    gulp         = require('gulp'),
    gutil        = require('gulp-util'),
    minifycss    = require('gulp-minify-css'),
    path         = require('path'),
    plumber      = require('gulp-plumber'),
    qunit        = require('gulp-qunit'),
    rename       = require('gulp-rename'),
    runSequence  = require('run-sequence'),
    sass         = require('gulp-sass'),
    source       = require('vinyl-source-stream'),
    sourcemaps   = require('gulp-sourcemaps'),
    uglify       = require('gulp-uglify'),
    watch        = require('gulp-watch');

// Base paths
var BASE_SRC_PATH       = path.join(__dirname, 'src'),
    BASE_GENERATED_PATH = path.join(__dirname, '.generated'),
    BASE_JS_PATH        = path.join(BASE_SRC_PATH, 'js'),
    BASE_CSS_PATH       = path.join(BASE_SRC_PATH, 'css');
    BASE_TEST_PATH      = path.join(__dirname, 'test');

// Task paths
var paths = {
  input: {
    css: path.join(BASE_CSS_PATH, 'peteshow.scss'),

    js: {
      vendor: [ ],

      src: [
        path.join(BASE_JS_PATH, 'peteshow.coffee')
      ]
    },

    testSync: [
      path.join(BASE_TEST_PATH, 'suite', '*.js'),
      path.join(BASE_TEST_PATH, 'vendor', '**', '*'),
      path.join(BASE_TEST_PATH, '*.html')
    ]
  },

  output: {
    css     : path.join(BASE_GENERATED_PATH, 'stylesheets'),
    js      : path.join(BASE_GENERATED_PATH, 'javascripts'),
    testSync: path.join(BASE_GENERATED_PATH)
  },

  watch: {
    css : path.join(BASE_SRC_PATH, 'css', '**', '*.scss'),
    js  : [
      path.join(BASE_SRC_PATH, 'js', '*.coffee'),
      path.join(BASE_SRC_PATH, 'templates', '*.hbs')
    ],
    testSync : [
      path.join(BASE_TEST_PATH, 'suite', '*.js'),
      path.join(BASE_TEST_PATH, 'vendor', '**', '*'),
      path.join(BASE_TEST_PATH, '*.html')
    ]
  },

  clean: [
    path.join(BASE_GENERATED_PATH, '**', '*')
  ],

  test: [ 'test/index.html' ]
};

// test : qunit
gulp.task('test', function() {
  return gulp.src(path.join(BASE_GENERATED_PATH, 'test_index.html'))
    .pipe(qunit());
});

// test : synchronize
gulp.task('test-sync', function() {
  return gulp.src(paths.input.testSync, { base: BASE_TEST_PATH })
    .pipe(gulp.dest(paths.output.testSync)
      .on('error', gutil.log)
      .on('error', gutil.beep));
});

//
// css
gulp.task('css', function() {
  return gulp.src(paths.input.css)
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass()
      .on('error', gutil.log)
      .on('error', gutil.beep))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(paths.output.css))
    .pipe(rename({suffix: '.min'}))
    .pipe(minifycss()
      .on('error', gutil.log)
      .on('error', gutil.beep))
    .pipe(gulp.dest(paths.output.css));
});

//
// js
gulp.task('js', function() {
  var jsStream = browserify(paths.input.js.src, {
      extensions: ['.coffee'],
      debug: true
    })
    .require(paths.input.js.vendor)
    .transform('coffeeify')
    .transform('hbsfy')
    .bundle()
    .on('error', gutil.log)
    .on('error', gutil.beep);

  // standard code
  jsStream
    .pipe(plumber())
    .pipe(source(paths.input.js.src[0]))
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(rename('peteshow.js'))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.output.js));

  // minified code
  jsStream
    .pipe(plumber())
    .pipe(source(paths.input.js.src[0]))
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(uglify({ compress: { negate_iife: false }})
      .on('error', gutil.log)
      .on('error', gutil.beep))
    .pipe(rename('peteshow.min.js'))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.output.js));

  return jsStream;
});

//
// Clean
gulp.task('clean', function() {
  return del(paths.clean);
});

//
// Watch
gulp.task('watch', ['pre-watch'], function() {
  watch(paths.watch.css, function(files, cb) {
    gulp
      .start('css', cb)
      .on('error', gutil.log);
  });
  watch(paths.watch.js, function(files, cb) {
    gulp
      .start('js', cb)
      .on('error', gutil.log);
  });
  watch(paths.watch.testSync, function(files, cb) {
    gulp
      .start('test-sync', cb)
      .on('error', gutil.log);
  });
});

gulp.task('pre-watch', function(callback) {
  runSequence('clean', 'css', 'js', 'test-sync', callback);
});

//
// Default
gulp.task('default', function(callback) {
  runSequence('clean', 'css', 'js', 'test-sync', 'test', callback);
});
<commit_msg>fixes scss sourcemaps for both standard and minified output<commit_after>// Require the needed packages
var browserify   = require('browserify'),
    buffer       = require('vinyl-buffer'),
    coffeeify    = require('coffeeify'),
    hbsfy        = require('hbsfy').configure({extensions: ['.hbs']}),
    del          = require('del'),
    gulp         = require('gulp'),
    gutil        = require('gulp-util'),
    minifycss    = require('gulp-minify-css'),
    path         = require('path'),
    plumber      = require('gulp-plumber'),
    qunit        = require('gulp-qunit'),
    rename       = require('gulp-rename'),
    runSequence  = require('run-sequence'),
    sass         = require('gulp-sass'),
    source       = require('vinyl-source-stream'),
    sourcemaps   = require('gulp-sourcemaps'),
    uglify       = require('gulp-uglify'),
    watch        = require('gulp-watch');

// Base paths
var BASE_SRC_PATH       = path.join(__dirname, 'src'),
    BASE_GENERATED_PATH = path.join(__dirname, '.generated'),
    BASE_JS_PATH        = path.join(BASE_SRC_PATH, 'js'),
    BASE_CSS_PATH       = path.join(BASE_SRC_PATH, 'css');
    BASE_TEST_PATH      = path.join(__dirname, 'test');

// Task paths
var paths = {
  input: {
    css: path.join(BASE_CSS_PATH, 'peteshow.scss'),

    js: {
      vendor: [ ],

      src: [
        path.join(BASE_JS_PATH, 'peteshow.coffee')
      ]
    },

    testSync: [
      path.join(BASE_TEST_PATH, 'suite', '*.js'),
      path.join(BASE_TEST_PATH, 'vendor', '**', '*'),
      path.join(BASE_TEST_PATH, '*.html')
    ]
  },

  output: {
    css     : path.join(BASE_GENERATED_PATH, 'stylesheets'),
    js      : path.join(BASE_GENERATED_PATH, 'javascripts'),
    testSync: path.join(BASE_GENERATED_PATH)
  },

  watch: {
    css : path.join(BASE_SRC_PATH, 'css', '**', '*.scss'),
    js  : [
      path.join(BASE_SRC_PATH, 'js', '*.coffee'),
      path.join(BASE_SRC_PATH, 'templates', '*.hbs')
    ],
    testSync : [
      path.join(BASE_TEST_PATH, 'suite', '*.js'),
      path.join(BASE_TEST_PATH, 'vendor', '**', '*'),
      path.join(BASE_TEST_PATH, '*.html')
    ]
  },

  clean: [
    path.join(BASE_GENERATED_PATH, '**', '*')
  ],

  test: [ 'test/index.html' ]
};

// test : qunit
gulp.task('test', function() {
  return gulp.src(path.join(BASE_GENERATED_PATH, 'test_index.html'))
    .pipe(qunit());
});

// test : synchronize
gulp.task('test-sync', function() {
  return gulp.src(paths.input.testSync, { base: BASE_TEST_PATH })
    .pipe(gulp.dest(paths.output.testSync)
      .on('error', gutil.log)
      .on('error', gutil.beep));
});

//
// css
gulp.task('css', function() {
  cssStream = gulp.src(paths.input.css)

  cssStream
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass()
      .on('error', gutil.log)
      .on('error', gutil.beep))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.output.css));

  cssStream
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass()
      .on('error', gutil.log)
      .on('error', gutil.beep))
    .pipe(rename({suffix: '.min'}))
    .pipe(minifycss()
      .on('error', gutil.log)
      .on('error', gutil.beep))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.output.css));
});

//
// js
gulp.task('js', function() {
  var jsStream = browserify(paths.input.js.src, {
      extensions: ['.coffee'],
      debug: true
    })
    .require(paths.input.js.vendor)
    .transform('coffeeify')
    .transform('hbsfy')
    .bundle()
    .on('error', gutil.log)
    .on('error', gutil.beep);

  // standard code
  jsStream
    .pipe(plumber())
    .pipe(source(paths.input.js.src[0]))
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(rename('peteshow.js'))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.output.js));

  // minified code
  jsStream
    .pipe(plumber())
    .pipe(source(paths.input.js.src[0]))
    .pipe(buffer())
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(uglify({ compress: { negate_iife: false }})
      .on('error', gutil.log)
      .on('error', gutil.beep))
    .pipe(rename('peteshow.min.js'))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(paths.output.js));

  return jsStream;
});

//
// Clean
gulp.task('clean', function() {
  return del(paths.clean);
});

//
// Watch
gulp.task('watch', ['pre-watch'], function() {
  watch(paths.watch.css, function(files, cb) {
    gulp
      .start('css', cb)
      .on('error', gutil.log);
  });
  watch(paths.watch.js, function(files, cb) {
    gulp
      .start('js', cb)
      .on('error', gutil.log);
  });
  watch(paths.watch.testSync, function(files, cb) {
    gulp
      .start('test-sync', cb)
      .on('error', gutil.log);
  });
});

gulp.task('pre-watch', function(callback) {
  runSequence('clean', 'css', 'js', 'test-sync', callback);
});

//
// Default
gulp.task('default', function(callback) {
  runSequence('clean', 'css', 'js', 'test-sync', 'test', callback);
});

{'fraction_non_alphanumeric': 0.20333367843462055, 'fraction_numerical': 0.00041412154467336163, 'mean_word_length': 2.806146572104019, 'pattern_counts': {'":': 0, '<': 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': '284417', 'n_tokens_mistral': 3552, 'n_tokens_neox': 3505, 'n_words': 532}