|
|
@ -117,28 +117,35 @@ module.exports = function(Meta) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Meta.js.minify = function(minify) {
|
|
|
|
Meta.js.minify = function(minify, callback) {
|
|
|
|
var minifier = Meta.js.minifierProc = fork('minifier.js', {
|
|
|
|
var minifier = Meta.js.minifierProc = fork('minifier.js', {
|
|
|
|
silent: true
|
|
|
|
silent: true
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
minifiedStream = minifier.stdio[1],
|
|
|
|
minifiedStream = minifier.stdio[1],
|
|
|
|
|
|
|
|
minifiedString = '',
|
|
|
|
mapStream = minifier.stdio[2],
|
|
|
|
mapStream = minifier.stdio[2],
|
|
|
|
|
|
|
|
mapString = '',
|
|
|
|
step = 0,
|
|
|
|
step = 0,
|
|
|
|
onComplete = function() {
|
|
|
|
onComplete = function() {
|
|
|
|
if (step === 0) {
|
|
|
|
if (step === 0) {
|
|
|
|
return step++;
|
|
|
|
return step++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Meta.js.cache = minifiedString;
|
|
|
|
|
|
|
|
Meta.js.map = mapString;
|
|
|
|
winston.info('[meta/js] Compilation complete');
|
|
|
|
winston.info('[meta/js] Compilation complete');
|
|
|
|
emitter.emit('meta:js.compiled');
|
|
|
|
emitter.emit('meta:js.compiled');
|
|
|
|
minifier.kill();
|
|
|
|
minifier.kill();
|
|
|
|
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
|
|
|
|
callback();
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
minifiedStream.on('data', function(buffer) {
|
|
|
|
minifiedStream.on('data', function(buffer) {
|
|
|
|
Meta.js.cache += buffer.toString();
|
|
|
|
minifiedString += buffer.toString();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
mapStream.on('data', function(buffer) {
|
|
|
|
mapStream.on('data', function(buffer) {
|
|
|
|
Meta.js.map += buffer.toString();
|
|
|
|
mapString += buffer.toString();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
minifier.on('message', function(message) {
|
|
|
|
minifier.on('message', function(message) {
|
|
|
@ -158,7 +165,11 @@ module.exports = function(Meta) {
|
|
|
|
case 'error':
|
|
|
|
case 'error':
|
|
|
|
winston.error('[meta/js] Could not compile client-side scripts! ' + message.payload.message);
|
|
|
|
winston.error('[meta/js] Could not compile client-side scripts! ' + message.payload.message);
|
|
|
|
minifier.kill();
|
|
|
|
minifier.kill();
|
|
|
|
process.exit();
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
|
|
|
|
callback(err);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
process.exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -185,7 +196,6 @@ module.exports = function(Meta) {
|
|
|
|
var jsPaths = scripts.map(function (jsPath) {
|
|
|
|
var jsPaths = scripts.map(function (jsPath) {
|
|
|
|
jsPath = path.normalize(jsPath);
|
|
|
|
jsPath = path.normalize(jsPath);
|
|
|
|
|
|
|
|
|
|
|
|
// if (jsPath.substring(0, 7) === 'plugins') {
|
|
|
|
|
|
|
|
var matches = _.map(plugins.staticDirs, function(realPath, mappedPath) {
|
|
|
|
var matches = _.map(plugins.staticDirs, function(realPath, mappedPath) {
|
|
|
|
if (jsPath.match(mappedPath)) {
|
|
|
|
if (jsPath.match(mappedPath)) {
|
|
|
|
return mappedPath;
|
|
|
|
return mappedPath;
|
|
|
@ -203,9 +213,6 @@ module.exports = function(Meta) {
|
|
|
|
winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + jsPath + '. Are you sure it is defined by a plugin?');
|
|
|
|
winston.warn('[meta.scripts.get] Could not resolve mapped path: ' + jsPath + '. Are you sure it is defined by a plugin?');
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// return path.join(__dirname, '../..', jsPath);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Meta.js.scripts.plugin = jsPaths.filter(Boolean);
|
|
|
|
Meta.js.scripts.plugin = jsPaths.filter(Boolean);
|
|
|
|