<commit_before>var requirejs = require('requirejs');
var fs = require('fs');
var util = require('util');

//var buildInjection = "var priority = [ 'pex-core.js']; \n";
var buildInjection = "var preloadCore = true; \n";

var configWebGL = {
  baseUrl : "src",
  name : "pex/Pex",
  out : "build/webgl/pex-core.js",
  packages:[
    { name:"plask",location:"../src/pex/node", main:"plask" },
    { name:"fs", location:"../src/pex/node", main:"fs" },
    { name:"path", location:"../src/pex/node", main:"path" },
    { name:"sys", location: "../src/pex/node", main: "sys" },
    { name:"events", location: "../src/pex/node", main: "events" }
  ],
  optimize : "none"
};

var configPlask = {
  baseUrl : "src",
  name : "pex/Pex",
  out : "build/plask/pex-core.js",
  exclude:[ "plask", "fs", "path", "sys", "events" ],
  packages:[
    { name:"plask",location:"../src/pex/node", main:"plask" },
    { name:"fs", location:"../src/pex/node", main:"fs" },
    { name:"path", location:"../src/pex/node", main:"path" },
    { name:"sys", location: "../src/pex/node", main: "sys" },
    { name:"events", location: "../src/pex/node", main: "events" }
  ],
  optimize : "none"
};

var filesToCopy = 0;

function copyFile(src, target, msg, prependText) {
  var is = fs.createReadStream(src)
  var os = fs.createWriteStream(target);

  filesToCopy++;

  if (prependText) {
    os.write(prependText)
  }

  util.pump(is, os, function() {
    console.log(msg);
    if (--filesToCopy == 0) {
      console.log("Done");
      process.exit(0);
    }
  });
}


requirejs.optimize(configWebGL, function (buildResponse) {
  copyFile("src/pex/pex-webgl.js", "build/webgl/pex-webgl.js", "WebGL core done", buildInjection);
  copyFile("src/pex/lib/require.js", "build/webgl/require.js", "WebGL requirejs done");
});

requirejs.optimize(configPlask, function (buildResponse) {
  copyFile("src/pex/pex-plask.js", "build/plask/pex-plask.js", "Plask core done", buildInjection);
});<commit_msg>Build config for node-webgl<commit_after>//http://blog.tojicode.com/2012/04/webgl-texture-utils-and-building.html
//http://requirejs.org/docs/node.html#nodeModules
//https://github.com/jrburke/amdefine

var requirejs = require('requirejs');
var fs = require('fs');
var util = require('util');

//var buildInjection = "var priority = [ 'pex-core.js']; \n";
var buildInjection = "var preloadCore = true; \n";

var configWebGL = {
  baseUrl : "src",
  name : "pex/Pex",
  out : "build/webgl/pex-core.js",
  packages:[
    { name:"plask",location:"../src/pex/node", main:"plask" },
    { name:"fs", location:"../src/pex/node", main:"fs" },
    { name:"path", location:"../src/pex/node", main:"path" },
    { name:"sys", location: "../src/pex/node", main: "sys" },
    { name:"events", location: "../src/pex/node", main: "events" }
  ],
  optimize : "none"
};

var configPlask = {
  baseUrl : "src",
  name : "pex/Pex",
  out : "build/plask/pex-core.js",
  exclude:[ "plask", "fs", "path", "sys", "events" ],
  packages:[
    { name:"plask",location:"../src/pex/node", main:"plask" },
    { name:"fs", location:"../src/pex/node", main:"fs" },
    { name:"path", location:"../src/pex/node", main:"path" },
    { name:"sys", location: "../src/pex/node", main: "sys" },
    { name:"events", location: "../src/pex/node", main: "events" }
  ],
  optimize : "none"
};

var configNode = {
  baseUrl : "src",
  name : "pex/Pex",
  out : "build/plask/pex-core.js",
  exclude:[ "plask", "fs", "path", "sys", "events" ],
  packages:[
    { name:"plask",location:"../src/pex/node", main:"plask" },
    { name:"fs", location:"../src/pex/node", main:"fs" },
    { name:"path", location:"../src/pex/node", main:"path" },
    { name:"sys", location: "../src/pex/node", main: "sys" },
    { name:"events", location: "../src/pex/node", main: "events" }
  ],
  optimize : "none"
};

var filesToCopy = 0;

function copyFile(src, target, msg, prependText) {
  var is = fs.createReadStream(src)
  var os = fs.createWriteStream(target);

  filesToCopy++;

  if (prependText) {
    os.write(prependText)
  }

  util.pump(is, os, function() {
    console.log(msg);
    if (--filesToCopy == 0) {
      console.log("Done");
      process.exit(0);
    }
  });
}


requirejs.optimize(configWebGL, function (buildResponse) {
  copyFile("src/pex/pex-webgl.js", "build/webgl/pex-webgl.js", "WebGL core done", buildInjection);
  copyFile("src/pex/lib/require.js", "build/webgl/require.js", "WebGL requirejs done");
});

requirejs.optimize(configPlask, function (buildResponse) {
  copyFile("src/pex/pex-plask.js", "build/plask/pex-plask.js", "Plask core done", buildInjection);
});

requirejs.optimize(configNode, function (buildResponse) {
  copyFile("src/pex/pex-node.js", "build/node/pex-node.js", "Node core done", buildInjection);
});


//requirejs.optimize(configAlmond, function (buildResponse) {
//  console.log("Almond done");
//});
{'fraction_non_alphanumeric': 0.22715136578352846, 'fraction_numerical': 0.0024645717806531116, 'mean_word_length': 3.687199230028874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '5114123', 'n_tokens_mistral': 1858, 'n_tokens_neox': 1779, 'n_words': 325}