Merge pull request #5728 from NodeBB/patch-pitaj

Assorted Fixes
v1.18.x
Julian Lam 8 years ago committed by GitHub
commit b4870654fc

1
.gitignore vendored

@ -63,3 +63,4 @@ build
*.log
test/files/normalise.jpg.png
test/files/normalise-resized.jpg
package-lock.json

@ -46,7 +46,6 @@
"json-2-csv": "^2.0.22",
"less": "^2.0.0",
"lodash": "^4.17.4",
"lodash.padstart": "^4.6.1",
"logrotate-stream": "^0.2.3",
"lru-cache": "4.0.2",
"mime": "^1.3.4",
@ -138,4 +137,4 @@
"url": "https://github.com/barisusakli"
}
]
}
}

@ -1,25 +1,53 @@
'use strict';
var path = require('path');
var fs = require('fs');
var async = require('async');
var file = require('../../file');
var themesController = {};
var defaultScreenshotPath = path.join(__dirname, '../../../public/images/themes/default.png');
themesController.get = function (req, res, next) {
var themeDir = path.join(__dirname, '../../../node_modules/' + req.params.theme);
file.exists(themeDir, function (err, exists) {
if (err || !exists) {
return next(err);
}
var themeConfig = require(path.join(themeDir, 'theme.json'));
var screenshotPath = path.join(themeDir, themeConfig.screenshot);
if (themeConfig.screenshot && file.existsSync(screenshotPath)) {
res.sendFile(screenshotPath);
} else {
res.sendFile(path.join(__dirname, '../../../public/images/themes/default.png'));
}
});
var themeDir = path.join(__dirname, '../../../node_modules', req.params.theme);
var themeConfigPath = path.join(themeDir, 'theme.json');
async.waterfall([
function (next) {
file.exists(themeConfigPath, function (err, exists) {
if (err) {
return next(err);
}
if (!exists) {
return next(Error('invalid-data'));
}
next();
});
},
function (next) {
fs.readFile(themeConfigPath, next);
},
function (themeConfig, next) {
try {
themeConfig = JSON.parse(themeConfig);
next(null, themeConfig.screenshot ? path.join(themeDir, themeConfig.screenshot) : defaultScreenshotPath);
} catch (e) {
next(e);
}
},
function (screenshotPath, next) {
file.exists(screenshotPath, function (err, exists) {
if (err) {
return next(err);
}
res.sendFile(exists ? screenshotPath : defaultScreenshotPath);
});
},
], next);
};
module.exports = themesController;

@ -3,7 +3,7 @@
var async = require('async');
var winston = require('winston');
var nconf = require('nconf');
var padstart = require('lodash.padstart');
var _ = require('lodash');
var cacheBuster = require('./cacheBuster');
var meta;
@ -122,7 +122,7 @@ function buildTargets(targets, parallel, callback) {
}));
all(targets, function (target, next) {
targetHandlers[target](parallel, step(padstart(target, length) + ' ', next));
targetHandlers[target](parallel, step(_.padStart(target, length) + ' ', next));
}, callback);
}

@ -0,0 +1,15 @@
'use strict';
module.exports = function () {
var debugArg = process.execArgv.find(function (arg) {
return /^--(debug|inspect)/.test(arg);
});
if (global.v8debug || debugArg) {
debugArg = debugArg ? debugArg.split('=') : ['--debug', 5859];
var num = parseInt(debugArg[1], 10) + 1;
return { execArgv: [debugArg[0] + '=' + num, '--nolazy'] };
}
return { execArgv: [] };
};

@ -107,15 +107,15 @@ function getTranslationTree(callback) {
// 2. old language string (en_GB)
// 3. corrected plugin defaultLang (en-US)
// 4. old plugin defaultLang (en_US)
async.eachLimit(plugins, 10, function (pluginData, done) {
async.eachLimit(plugins, 20, function (pluginData, done) {
var pluginLanguages = path.join(__dirname, '../../node_modules/', pluginData.id, pluginData.languages);
var defaultLang = pluginData.defaultLang || 'en-GB';
async.some([
lang,
lang.replace('-', '_').replace('-x-', '@'),
defaultLang.replace('_', '-').replace('@', '-x-'),
async.eachSeries([
defaultLang.replace('-', '_').replace('-x-', '@'),
defaultLang.replace('_', '-').replace('@', '-x-'),
lang.replace('-', '_').replace('-x-', '@'),
lang,
], function (language, next) {
fs.readFile(path.join(pluginLanguages, language, namespace + '.json'), function (err, buffer) {
if (err) {

@ -11,30 +11,9 @@ var postcss = require('postcss');
var autoprefixer = require('autoprefixer');
var clean = require('postcss-clean');
var Minifier = module.exports;
function setupDebugging() {
/**
* Check if the parent process is running with the debug option --debug (or --debug-brk)
*/
var forkProcessParams = {};
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
/**
* use the line below if you want to debug minifier.js script too (or even --debug-brk option, but
* you'll have to setup your debugger and connect to the forked process)
*/
// forkProcessParams = { execArgv: ['--debug=' + (global.process.debugPort + 1), '--nolazy'] };
/**
* otherwise, just clean up --debug/--debug-brk options which are set up by default from the parent one
*/
forkProcessParams = {
execArgv: [],
};
}
var debugParams = require('./debugParams');
return forkProcessParams;
}
var Minifier = module.exports;
var pool = [];
var free = [];
@ -68,7 +47,7 @@ function getChild() {
return free.shift();
}
var forkProcessParams = setupDebugging();
var forkProcessParams = debugParams();
var proc = childProcess.fork(__filename, [], Object.assign({}, forkProcessParams, {
cwd: __dirname,
env: {

@ -1,9 +1,10 @@
'use strict';
var fork = require('child_process').fork;
var path = require('path');
var debugParams = require('./meta/debugParams');
exports.hash = function (rounds, password, callback) {
forkChild({ type: 'hash', rounds: rounds, password: password }, callback);
};
@ -16,11 +17,7 @@ exports.compare = function (password, hash, callback) {
};
function forkChild(message, callback) {
var forkProcessParams = {};
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
forkProcessParams = { execArgv: ['--debug=' + (5859), '--nolazy'] };
}
var child = fork(path.join(__dirname, 'bcrypt'), [], forkProcessParams);
var child = fork(path.join(__dirname, 'bcrypt'), [], debugParams());
child.on('message', function (msg) {
if (msg.err) {

@ -107,7 +107,7 @@ module.exports = function (Plugins) {
}
function runNpmCommand(command, pkgName, version, callback) {
require('child_process').execFile((process.platform === 'win32') ? 'npm.cmd' : 'npm', [command, pkgName + (command === 'install' ? '@' + version : '')], function (err, stdout) {
require('child_process').execFile((process.platform === 'win32') ? 'npm.cmd' : 'npm', [command, pkgName + (command === 'install' ? '@' + version : ''), '--no-save'], function (err, stdout) {
if (err) {
return callback(err);
}

Loading…
Cancel
Save