twreporter-react
Version:
React-Redux site for The Reporter Foundation in Taiwan
53 lines (45 loc) • 1.75 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var cluster, languages, natives, path,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
cluster = require("cluster");
path = require("path");
natives = ['assert', 'buffer', 'child_process', 'cluster', 'console', 'constants', 'crypto', 'dgram', 'dns', 'domain', 'events', 'freelist', 'fs', 'http', 'https', 'module', 'net', 'os', 'path', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'sys', 'timers', 'tls', 'tty', 'url', 'util', 'vm', 'zlib'];
languages = {
".coffee": "coffee-script"
};
cluster.worker.on("message", function(options) {
var _load_orig, ext, main, module;
main = path.resolve(process.cwd(), options.main);
if (options.hook) {
module = require("module");
_load_orig = module._load;
module._load = function(name, parent, isMain) {
var file;
file = module._resolveFilename(name, parent);
if (options.includeModules || file.indexOf("node_modules") === -1) {
if (!(indexOf.call(natives, file) >= 0 || file === main)) {
cluster.worker.send({
file: file
});
}
}
return _load_orig(name, parent, isMain);
};
}
ext = path.extname(options.main);
if (languages[ext]) {
require(languages[ext]);
}
if (options.language) {
require(options.language);
}
return require(main);
});
process.on("uncaughtException", function(err) {
cluster.worker.send({
err: (err != null ? err.stack : void 0) || err
});
return cluster.worker.kill();
});
}).call(this);