|
|
@ -42,7 +42,10 @@ web.install = function (port) {
|
|
|
|
extended: true,
|
|
|
|
extended: true,
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
async.parallel([compileLess, compileJS], function () {
|
|
|
|
async.parallel([compileLess, compileJS], function (err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
winston.error(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
setupRoutes();
|
|
|
|
setupRoutes();
|
|
|
|
launchExpress(port);
|
|
|
|
launchExpress(port);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -152,13 +155,32 @@ function compileLess(callback) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function compileJS(callback) {
|
|
|
|
function compileJS(callback) {
|
|
|
|
var scriptPath = path.join(__dirname, '..');
|
|
|
|
var code = '';
|
|
|
|
var result = uglify.minify(scripts.map(function (script) {
|
|
|
|
async.eachSeries(scripts, function (srcPath, next) {
|
|
|
|
return path.join(scriptPath, script);
|
|
|
|
fs.readFile(path.join(__dirname, '..', srcPath), function (err, buffer) {
|
|
|
|
}));
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return next(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fs.writeFile(path.join(__dirname, '../public/installer.min.js'), result.code, callback);
|
|
|
|
code += buffer.toString();
|
|
|
|
|
|
|
|
next();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, function (err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
var minified = uglify.minify(code, {
|
|
|
|
|
|
|
|
compress: false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!minified.code) {
|
|
|
|
|
|
|
|
return callback(new Error('[[error:failed-to-minify]]'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.writeFile(path.join(__dirname, '../public/installer.min.js'), minified.code, callback);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
callback(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = web;
|
|
|
|
module.exports = web;
|
|
|
|