<commit_before>'use strict';

var fs = require('./util/fs');
var manifest = require('./manifest');
var pack = require('./packer-pack');

var AdmZip = require('adm-zip');
var Promise = require('bluebird');
var path = require('path');

var UNKNOWN_LICENSE = 'Unknown License';

module.exports = build;

function build(cfg) {
  return Promise.props(cfg)
  .then(function (cfg) {

    if (!cfg.entry) {
      throw new Error("No entry specified");
    }

    if (!cfg.package) {
      cfg.package = getPackage(cfg);
    }

    if (!cfg.manifest) {
      cfg.manifest = getManifest(cfg);
    }

    if (!cfg.license) {
      cfg.license = getLicense(cfg);
    }

    return Promise.props(cfg);
  })
  .then(function (cfg) {

    cfg.packed = pack(cfg.entry, cfg);

    return Promise.props(cfg);
  })
  .then(function (cfg) {

    var titaniumManifest = cfg.package.titaniumManifest || {};

    var moduleid = titaniumManifest.moduleid || cfg.package.name;
    var version = cfg.package.version + (cfg.noDependencies ? '-bare' : '');
    var pkg = cfg.package;

    pkg._nativeDependencies = cfg.packed.nativeDependencies;

    cfg.zipname = moduleid + '-commonjs-' + version + '.zip';
    cfg.internalPath = 'modules/commonjs/' + moduleid + '/' + version;

    var zip = new AdmZip();

    zip.addFileToModule = addFileToModule.bind(null, zip, cfg);
    zip.writeModule = writeModule.bind(null, zip, cfg);

    zip.addFileToModule('/manifest', cfg.manifest);
    zip.addFileToModule('/package.json', JSON.stringify(cfg.package, null, 2));
    zip.addFileToModule('/' + moduleid + '.js', cfg.packed.source);<commit_msg>Zipfiles must have lower case names, fixes #29<commit_after>'use strict';

var fs = require('./util/fs');
var manifest = require('./manifest');
var pack = require('./packer-pack');

var AdmZip = require('adm-zip');
var Promise = require('bluebird');
var path = require('path');

var UNKNOWN_LICENSE = 'Unknown License';

module.exports = build;

function build(cfg) {
  return Promise.props(cfg)
  .then(function (cfg) {

    if (!cfg.entry) {
      throw new Error("No entry specified");
    }

    if (!cfg.package) {
      cfg.package = getPackage(cfg);
    }

    if (!cfg.manifest) {
      cfg.manifest = getManifest(cfg);
    }

    if (!cfg.license) {
      cfg.license = getLicense(cfg);
    }

    return Promise.props(cfg);
  })
  .then(function (cfg) {

    cfg.packed = pack(cfg.entry, cfg);

    return Promise.props(cfg);
  })
  .then(function (cfg) {

    var titaniumManifest = cfg.package.titaniumManifest || {};

    var moduleid = titaniumManifest.moduleid || cfg.package.name;
    var version = cfg.package.version + (cfg.noDependencies ? '-bare' : '');
    var pkg = cfg.package;

    pkg._nativeDependencies = cfg.packed.nativeDependencies;

    cfg.zipname = (moduleid + '-commonjs-' + version + '.zip').toLowerCase();
    cfg.internalPath = 'modules/commonjs/' + moduleid + '/' + version;

    var zip = new AdmZip();

    zip.addFileToModule = addFileToModule.bind(null, zip, cfg);
    zip.writeModule = writeModule.bind(null, zip, cfg);

    zip.addFileToModule('/manifest', cfg.manifest);
    zip.addFileToModule('/package.json', JSON.stringify(cfg.package, null, 2));
    zip.addFileToModule('/' + moduleid + '.js', cfg.packed.source);
{'fraction_non_alphanumeric': 0.1638693927372597, 'fraction_numerical': 0.0012206286237412267, 'mean_word_length': 3.318840579710145, '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': '7206104', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1023, 'n_words': 226}