0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Changed /^testing/ regexp use to startsWith method

no issue

- `startsWith` method is way easier to read and understand. also, **probably** has better performance comparing to building up a regexp and then matching
This commit is contained in:
Naz 2021-11-19 15:51:19 +04:00 committed by naz
parent ae397eecdf
commit d0dfac438d
4 changed files with 4 additions and 4 deletions

View file

@ -276,7 +276,7 @@ async function initBackgroundServices({config}) {
themeService.loadInactiveThemes(); themeService.loadInactiveThemes();
// we don't want to kick off background services that will interfere with tests // we don't want to kick off background services that will interfere with tests
if (process.env.NODE_ENV.match(/^testing/)) { if (process.env.NODE_ENV.startsWith('test')) {
return; return;
} }

View file

@ -12,7 +12,7 @@ module.exports = {
!hasScheduled && !hasScheduled &&
config.get('emailAnalytics') && config.get('emailAnalytics') &&
config.get('backgroundJobs:emailAnalytics') && config.get('backgroundJobs:emailAnalytics') &&
!process.env.NODE_ENV.match(/^testing/) !process.env.NODE_ENV.startsWith('test')
) { ) {
// Don't register email analytics job if we have no emails, // Don't register email analytics job if we have no emails,
// processor usage from many sites spinning up threads can be high. // processor usage from many sites spinning up threads can be high.

View file

@ -10,7 +10,7 @@ let storagePath = config.getContentPath('data');
// TODO: remove this hack in favor of loading from the content path when it's possible to do so // TODO: remove this hack in favor of loading from the content path when it's possible to do so
// by mocking content folders in pre-boot phase // by mocking content folders in pre-boot phase
if (process.env.NODE_ENV.match(/^testing/)){ if (process.env.NODE_ENV.startsWith('test')){
storagePath = config.get('paths').urlCache; storagePath = config.get('paths').urlCache;
// NOTE: prevents test suites from overwriting cache fixtures. // NOTE: prevents test suites from overwriting cache fixtures.

View file

@ -50,7 +50,7 @@ module.exports.getAll = () => {
const labs = _.cloneDeep(settingsCache.get('labs')) || {}; const labs = _.cloneDeep(settingsCache.get('labs')) || {};
ALPHA_FEATURES.forEach((alphaKey) => { ALPHA_FEATURES.forEach((alphaKey) => {
if (labs[alphaKey] && !(config.get('enableDeveloperExperiments') || process.env.NODE_ENV.match(/^testing/))) { if (labs[alphaKey] && !(config.get('enableDeveloperExperiments') || process.env.NODE_ENV.startsWith('test'))) {
delete labs[alphaKey]; delete labs[alphaKey];
} }
}); });