refactor: shared constants (#8707)

define plugin name and theme name regexs in one location for consistency

define various shared paths in one place for consistency
This commit is contained in:
Peter Jaszkowiak
2020-10-01 21:02:44 -06:00
committed by GitHub
parent e60357d20d
commit 1aa336d837
20 changed files with 130 additions and 136 deletions

View File

@@ -1,12 +1,12 @@
'use strict';
var nconf = require('nconf');
var url = require('url');
var winston = require('winston');
var path = require('path');
const nconf = require('nconf');
const url = require('url');
const winston = require('winston');
const path = require('path');
var pkg = require('../package.json');
var dirname = require('./cli/paths').baseDir;
const pkg = require('../package.json');
const { paths } = require('./constants');
function setupWinston() {
if (!winston.format) {
@@ -49,10 +49,10 @@ function loadConfig(configFile) {
});
nconf.defaults({
base_dir: dirname,
themes_path: path.join(dirname, 'node_modules'),
base_dir: paths.baseDir,
themes_path: paths.nodeModules,
upload_path: 'public/uploads',
views_dir: path.join(dirname, 'build/public/templates'),
views_dir: path.join(paths.baseDir, 'build/public/templates'),
version: pkg.version,
isCluster: false,
isPrimary: true,
@@ -72,8 +72,8 @@ function loadConfig(configFile) {
nconf.set('runJobs', nconf.get('isPrimary') && !nconf.get('jobsDisabled'));
// Ensure themes_path is a full filepath
nconf.set('themes_path', path.resolve(dirname, nconf.get('themes_path')));
nconf.set('core_templates_path', path.join(dirname, 'src/views'));
nconf.set('themes_path', path.resolve(paths.baseDir, nconf.get('themes_path')));
nconf.set('core_templates_path', path.join(paths.baseDir, 'src/views'));
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates'));
nconf.set('upload_path', path.resolve(nconf.get('base_dir'), nconf.get('upload_path')));