Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 67 lines (56 sloc) 2.2 KB
#!/usr/bin/env node
var
path = require('path')
resources = require('../lib/static_resources.js'),
config = require('../lib/configuration.js'),
i18n = require('../lib/i18n'),
mkdirp = require('mkdirp'),
computecluster = require('compute-cluster');
const staticPath = path.join(__dirname, '..', 'resources', 'static');
var langs = config.get('supported_languages');
var all = resources.all(langs);
var cc = new computecluster({
module: path.join(__dirname, 'compress-worker.js'),
max_backlog: -1
});
// first and foremost we'll "generate templates" - which is to concatenate
// a bunch of ejs into a javascript file
// NOTE: env setting could be cleaned up here, this is like this to minimally
// change things during migration of compress{,-locales}.sh to javascript
process.env['BUILD_DIR'] = path.join(staticPath, "build");
mkdirp.sync(process.env['BUILD_DIR']);
process.env['TEMPLATE_DIR'] = path.join(staticPath, "dialog", "views");
require('./create_templates.js')();
var leftToBuild = Object.keys(all).length;
var errors = 0;
Object.keys(all).forEach(function(resource) {
// in dev, '/shared/templates.js' creates an empty object and templates
// are fetched on demand.
// in prod '/build/templates.js' has all templates glommed into it,
// and is bundled into the Big Minified Piles Of Resources we ship.
// Here we sub the former with the latter.
var ix = all[resource].indexOf('/common/js/templates.js');
if (ix !== -1) all[resource].splice(ix, 1, '/build/templates.js');
// remove translation files from default and debug languages. #1905
[ config.get('debug_lang'), config.get('default_lang') ].forEach(function(l) {
var file = '/i18n/' + i18n.localeFrom(l) + '/client.json';
var ix = all[resource].indexOf(file);
if (-1 !== ix) all[resource].splice(ix, 1);
});
cc.enqueue({
file: resource,
deps: all[resource],
staticPath: staticPath
}, function(err, r) {
if (err || r.error) {
console.log("failed to build", resource,":", err || r.error);
errors++;
} else {
console.log("built", resource, "in", r.time + "s" + (r.info ? " (" + r.info + ")" : ""));
}
if (--leftToBuild == 0) {
cc.exit();
if (errors) process.exit(1);
}
});
});
Jump to Line
Something went wrong with that request. Please try again.