<commit_before>var babel = require('gulp-babel');
var concat = require('gulp-concat');
var cssnano = require('gulp-cssnano');
var customizer = require('../customizer/lib');
var File = require('vinyl');
var fs = require('fs');
var gulp = require('gulp');
var If = require('gulp-if');
var path = require('path');
var Readable = require('stream').Readable;
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var rimraf = require('rimraf');
var sass = require('gulp-sass');
var source = require('vinyl-source-stream');
var touch = require('touch');
var uglify = require('gulp-uglify');
var yaml = require('js-yaml').safeLoad;
var yargs = require('yargs');
var zip = require('gulp-zip');

var ARGS = require('yargs').argv;
var FOUNDATION_VERSION = require('../package.json').version;
var OUTPUT_DIR = ARGS.output;
var CUSTOMIZER_CONFIG;
var MODULE_LIST;
var VARIABLE_LIST;

// Load the configuration file for the customizer. It's a list of modules to load and Sass variables to override
gulp.task('customizer:loadConfig', function(done) {
  fs.readFile('customizer/config.yml', function(err, data) {
    var moduleListPath = ARGS.modules;
    var moduleList = require(moduleListPath);

    CUSTOMIZER_CONFIG = yaml(data.toString());
    MODULE_LIST = moduleList.modules;
    VARIABLE_LIST = moduleList.variables;
    done();
  });
});

// Creates a Sass file from the module/variable list and creates foundation.css and foundation.min.css
gulp.task('customizer:sass', ['customizer:loadConfig'], function() {
  var sassFile = customizer.sass(CUSTOMIZER_CONFIG, MODULE_LIST, VARIABLE_LIST);

  // Create a stream with our makeshift Sass file
  var stream = new Readable({ objectMode: true });
  stream._read = function() {};
  stream.push(new File({
    path: 'foundation.scss',
    contents: new Buffer(sassFile)
  }));
  stream.push(null);

  return stream
    .pipe(sass({
      includePaths: [
        'scss',
        'node_modules/motion-ui/src'
      ]
    }))
    .pipe(gulp.dest('.customizer/css'))
    .pipe(cssnano())
    .pipe(rename('foundation.min.css'))
    .pipe(gulp.dest(path.join(OUTPUT_DIR, 'css')));
});

// Creates a Foundation JavaScript file from the module list, and also copies dependencies (jQuery, what-input)
gulp.task('customizer:javascript', ['customizer:loadConfig'], function() {
  var jsPaths = customizer.js(CUSTOMIZER_CONFIG, MODULE_LIST);

  return gulp.src(jsPaths)
    .pipe(babel())
    .pipe(concat('foundation.js'))
    .pipe(gulp.dest('.customizer/js/vendor'))
    .pipe(uglify())
    .pipe(rename('foundation.min.js'))
    .pipe(gulp.src([
      'node_modules/jquery/dist/jquery.js',
      'node_modules/what-input/what-input.js'
    ]))
    .pipe(gulp.dest(path.join(OUTPUT_DIR, 'js/vendor')));
});

// Copies the boilerplate index.html to the custom download folder
gulp.task('customizer:html', ['customizer:loadConfig'], function() {
  var rtlEnabled = VARIABLE_LIST['global-text-direction'] && VARIABLE_LIST['global-text-direction'] === 'rtl';

  return gulp.src('customizer/index.html')
    .pipe(If(rtlEnabled, replace('ltr', 'rtl')))
    .pipe(gulp.dest(OUTPUT_DIR));
});

// Creates a custom build by:
//   - Generating a CSS file
//   - Generating a JS file
//   - Copying the index.html file
//   - Creating a blank app.css file
//   - Creating an app.js file with Foundation initialization code
gulp.task('customizer', ['customizer:sass', 'customizer:javascript', 'customizer:html'], function(done) {
  touch(path.join(OUTPUT_DIR, 'css/app.css'));
  touch(path.join(OUTPUT_DIR, 'js/app.js'));
  fs.writeFileSync(path.join(OUTPUT_DIR, 'js/app.js'), '$(document).foundation()\n');

  gulp.src(path.join(OUTPUT_DIR, '/**/*'))
    .pipe(zip(path.basename(OUTPUT_DIR) + '.zip'))
    .pipe(gulp.dest('.'))
    .on('finish', function() {
      rimraf(OUTPUT_DIR, done);
    });
});
<commit_msg>Allow paths to be passed to the --output flag of the customizer<commit_after>var babel = require('gulp-babel');
var concat = require('gulp-concat');
var cssnano = require('gulp-cssnano');
var customizer = require('../customizer/lib');
var File = require('vinyl');
var fs = require('fs');
var gulp = require('gulp');
var If = require('gulp-if');
var path = require('path');
var Readable = require('stream').Readable;
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var rimraf = require('rimraf');
var sass = require('gulp-sass');
var source = require('vinyl-source-stream');
var touch = require('touch');
var uglify = require('gulp-uglify');
var yaml = require('js-yaml').safeLoad;
var yargs = require('yargs');
var zip = require('gulp-zip');

var ARGS = require('yargs').argv;
var FOUNDATION_VERSION = require('../package.json').version;
var OUTPUT_DIR = ARGS.output;
var CUSTOMIZER_CONFIG;
var MODULE_LIST;
var VARIABLE_LIST;

// Load the configuration file for the customizer. It's a list of modules to load and Sass variables to override
gulp.task('customizer:loadConfig', function(done) {
  fs.readFile('customizer/config.yml', function(err, data) {
    var moduleListPath = ARGS.modules;
    var moduleList = require(moduleListPath);

    CUSTOMIZER_CONFIG = yaml(data.toString());
    MODULE_LIST = moduleList.modules;
    VARIABLE_LIST = moduleList.variables;
    done();
  });
});

// Creates a Sass file from the module/variable list and creates foundation.css and foundation.min.css
gulp.task('customizer:sass', ['customizer:loadConfig'], function() {
  var sassFile = customizer.sass(CUSTOMIZER_CONFIG, MODULE_LIST, VARIABLE_LIST);

  // Create a stream with our makeshift Sass file
  var stream = new Readable({ objectMode: true });
  stream._read = function() {};
  stream.push(new File({
    path: 'foundation.scss',
    contents: new Buffer(sassFile)
  }));
  stream.push(null);

  return stream
    .pipe(sass({
      includePaths: [
        'scss',
        'node_modules/motion-ui/src'
      ]
    }))
    .pipe(gulp.dest('.customizer/css'))
    .pipe(cssnano())
    .pipe(rename('foundation.min.css'))
    .pipe(gulp.dest(path.join(OUTPUT_DIR, 'css')));
});

// Creates a Foundation JavaScript file from the module list, and also copies dependencies (jQuery, what-input)
gulp.task('customizer:javascript', ['customizer:loadConfig'], function() {
  var jsPaths = customizer.js(CUSTOMIZER_CONFIG, MODULE_LIST);

  return gulp.src(jsPaths)
    .pipe(babel())
    .pipe(concat('foundation.js'))
    .pipe(gulp.dest('.customizer/js/vendor'))
    .pipe(uglify())
    .pipe(rename('foundation.min.js'))
    .pipe(gulp.src([
      'node_modules/jquery/dist/jquery.js',
      'node_modules/what-input/what-input.js'
    ]))
    .pipe(gulp.dest(path.join(OUTPUT_DIR, 'js/vendor')));
});

// Copies the boilerplate index.html to the custom download folder
gulp.task('customizer:html', ['customizer:loadConfig'], function() {
  var rtlEnabled = VARIABLE_LIST['global-text-direction'] && VARIABLE_LIST['global-text-direction'] === 'rtl';

  return gulp.src('customizer/index.html')
    .pipe(If(rtlEnabled, replace('ltr', 'rtl')))
    .pipe(gulp.dest(OUTPUT_DIR));
});

// Creates a custom build by:
//   - Generating a CSS file
//   - Generating a JS file
//   - Copying the index.html file
//   - Creating a blank app.css file
//   - Creating an app.js file with Foundation initialization code
gulp.task('customizer', ['customizer:sass', 'customizer:javascript', 'customizer:html'], function(done) {
  var outputFolder = path.dirname(OUTPUT_DIR);
  var outputFileName = path.basename(OUTPUT_DIR);

  touch(path.join(OUTPUT_DIR, 'css/app.css'));
  touch(path.join(OUTPUT_DIR, 'js/app.js'));
  fs.writeFileSync(path.join(OUTPUT_DIR, 'js/app.js'), '$(document).foundation()\n');

  gulp.src(path.join(OUTPUT_DIR, '/**/*'))
    .pipe(zip(path.basename(outputFileName) + '.zip'))
    .pipe(gulp.dest(outputFolder))
    .on('finish', function() {
      rimraf(OUTPUT_DIR, done);
    });
});

{'fraction_non_alphanumeric': 0.16791470998857724, 'fraction_numerical': 0.0, 'mean_word_length': 4.360544217687075, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6567858', 'n_tokens_mistral': 2638, 'n_tokens_neox': 2596, 'n_words': 567}