Skip to content

Node.js based forum software built for the modern web

filter files before minify, removed unused ctime

barisusaklid1b4efeaa37a
diff --git a/minifier.js b/minifier.js
index a5b19e3f26..a56578898d 100644
--- a/minifier.js
+++ b/minifier.js
@@ -15,6 +15,10 @@ var uglifyjs = require('uglify-js'),
Minifier.js.minify = function (scripts, minify, callback) {
var options = {};
+ scripts = scripts.filter(function(file) {
+ return fs.existsSync(file);
+ });
+
if (!minify) {
options.sourceMapURL = '/nodebb.min.js.map';
options.outSourceMap = 'nodebb.min.js.map';
@@ -32,7 +36,9 @@ Minifier.js.minify = function (scripts, minify, callback) {
} catch(err) {
process.send({
action: 'error',
- error: err
+ error: {
+ message: err.message
+ }
});
}
};
diff --git a/src/meta.js b/src/meta.js
index d3b341b6a3..d33515d5f3 100644
--- a/src/meta.js
+++ b/src/meta.js
@@ -281,32 +281,31 @@ var fs = require('fs'),
},
prepare: function (callback) {
plugins.fireHook('filter:scripts.get', this.scripts, function(err, scripts) {
- var ctime,
- jsPaths = scripts.map(function (jsPath) {
- jsPath = path.normalize(jsPath);
-
- if (jsPath.substring(0, 7) === 'plugins') {
- var matches = _.map(plugins.staticDirs, function(realPath, mappedPath) {
- if (jsPath.match(mappedPath)) {
- return mappedPath;
- } else {
- return null;
- }
- }).filter(function(a) { return a; });
-
- if (matches.length) {
- var relPath = jsPath.slice(('plugins/' + matches[0]).length),
- pluginId = matches[0].split(path.sep)[0];
+ var jsPaths = scripts.map(function (jsPath) {
+ jsPath = path.normalize(jsPath);
- return plugins.staticDirs[matches[0]] + relPath;
+ if (jsPath.substring(0, 7) === 'plugins') {
+ var matches = _.map(plugins.staticDirs, function(realPath, mappedPath) {
+ if (jsPath.match(mappedPath)) {
+ return mappedPath;
} else {
- winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + jsPath + '. Are you sure it is defined by a plugin?');
return null;
}
+ }).filter(function(a) { return a; });
+
+ if (matches.length) {
+ var relPath = jsPath.slice(('plugins/' + matches[0]).length),
+ pluginId = matches[0].split(path.sep)[0];
+
+ return plugins.staticDirs[matches[0]] + relPath;
} else {
- return path.join(__dirname, '..', '/public', jsPath);
+ winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + jsPath + '. Are you sure it is defined by a plugin?');
+ return null;
}
- });
+ } else {
+ return path.join(__dirname, '..', '/public', jsPath);
+ }
+ });
Meta.js.scripts = jsPaths.filter(function(path) {
return path !== null;
@@ -332,8 +331,7 @@ var fs = require('fs'),
emitter.emit('meta:js.compiled');
} else {
- winston.error('[meta/js] Could not compile client-side scripts!');
- winston.error('[meta/js] ' + payload.error.message);
+ winston.error('[meta/js] Could not compile client-side scripts! ' + payload.error.message);
minifier.kill();
process.exit();
}