Merge branch 'master' into Fix_fulltextindex

This commit is contained in:
Jim LAURIE 2018-09-16 11:48:39 +02:00 committed by GitHub
commit 3931355db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 2 deletions

View File

@ -12,7 +12,7 @@ const _ = require('lodash');
// Following this discussion https://stackoverflow.com/questions/18082/validate-decimal-numbers-in-javascript-isnumeric this function is the best implem to determine if a value is a valid number candidate
const isNumeric = (value) => {
return !isNaN(parseFloat(value)) && isFinite(value);
return !_.isObject(value) && !isNaN(parseFloat(value)) && isFinite(value);
};
/* eslint-disable prefer-template */

View File

@ -382,6 +382,31 @@ const enableHookNestedDependencies = function (name, flattenHooksConfig, force =
}
};
/**
* Allow dynamic config values through
* the native ES6 template string function.
*/
const regex = /\$\{[^()]*\}/g;
const excludeConfigPaths = ['info.scripts'];
const templateConfigurations = function (obj, configPath = '') {
// Allow values which looks like such as
// an ES6 literal string without parenthesis inside (aka function call).
// Exclude config with conflicting syntax (e.g. npm scripts).
return Object.keys(obj).reduce((acc, key) => {
if (isPlainObject(obj[key]) && !isString(obj[key])) {
acc[key] = templateConfigurations(obj[key], `${configPath}.${key}`);
} else if (isString(obj[key])
&& !excludeConfigPaths.includes(configPath.substr(1))
&& obj[key].match(regex) !== null) {
acc[key] = eval('`' + obj[key] + '`'); // eslint-disable-line prefer-template
} else {
acc[key] = obj[key];
}
return acc;
}, {});
};
const isAdminInDevMode = function () {
try {
fs.accessSync(path.resolve(this.config.appPath, 'admin', 'admin', 'build', 'index.html'), fs.constants.R_OK | fs.constants.W_OK);