Skip to content

Commit

Permalink
fix: #11396, removal of base_templates_path variable
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Mar 27, 2023
1 parent 491487a commit 7cb2e02
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/meta/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function beforeBuild(targets) {
await plugins.prepareForBuild(targets);
await mkdirp(path.join(__dirname, '../../build/public'));
} catch (err) {
winston.error(`[build] Encountered error preparing for build\n${err.stack}`);
winston.error(`[build] Encountered error preparing for build`);
throw err;
}
}
Expand Down Expand Up @@ -197,7 +197,7 @@ exports.build = async function (targets, options) {
await cacheBuster.write();
winston.info(`[build] Asset compilation successful. Completed in ${totalTime}sec.`);
} catch (err) {
winston.error(`[build] Encountered error during build step\n${err.stack ? err.stack : err}`);
winston.error(`[build] Encountered error during build step`);
throw err;
}
};
Expand Down
1 change: 0 additions & 1 deletion src/meta/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ async function getTemplateDirs(activePlugins) {
theme = themeConfig.baseTheme;
}

themeTemplates.push(nconf.get('base_templates_path'));
themeTemplates = _.uniq(themeTemplates.reverse());

const coreTemplatesPath = nconf.get('core_templates_path');
Expand Down
7 changes: 5 additions & 2 deletions src/meta/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,24 @@ Themes.setupPaths = async () => {
const themeObj = data.themesData.find(themeObj => themeObj.id === themeId);

if (!themeObj) {
throw new Error('[[error:theme-not-found]]');
throw new Error('theme-not-found');
}

Themes.setPath(themeObj);
};

Themes.setPath = function (themeObj) {
// Theme's templates path
let themePath = nconf.get('base_templates_path');
let themePath;
const fallback = path.join(nconf.get('themes_path'), themeObj.id, 'templates');

if (themeObj.templates) {
themePath = path.join(nconf.get('themes_path'), themeObj.id, themeObj.templates);
} else if (file.existsSync(fallback)) {
themePath = fallback;
} else {
winston.error('[themes] Unable to resolve this theme\'s templates. Expected to be at "templates/" or defined in the "templates" property of "theme.json"');
throw new Error('theme-missing-templates');
}

nconf.set('theme_templates_path', themePath);
Expand Down
1 change: 0 additions & 1 deletion src/prestart.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function loadConfig(configFile) {
// Ensure themes_path is a full filepath
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-harmony/templates'));

nconf.set('upload_path', path.resolve(nconf.get('base_dir'), nconf.get('upload_path')));
nconf.set('upload_url', '/assets/uploads');
Expand Down

0 comments on commit 7cb2e02

Please sign in to comment.