mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 01:03:23 +03:00
fc664ac697
- Having to remember to add files to an index.js is a PITA - We already have glob as a dependency, so use that - This requires that the file prev_next be renamed to prev_post, which is what it's called as by default - next_post is an alias of next_post - so this reflects that more closely
16 lines
476 B
JavaScript
16 lines
476 B
JavaScript
const glob = require('glob');
|
|
const path = require('path');
|
|
|
|
const helpers = {};
|
|
|
|
// We use glob here because it's already a dependency
|
|
// If we want to get rid of glob we could use E.g. requiredir
|
|
// Or require('fs').readdirSync(__dirname + '/')
|
|
let helperFiles = glob.sync('!(index).js', {cwd: __dirname});
|
|
helperFiles.forEach((helper) => {
|
|
let name = helper.replace(/.js$/, '');
|
|
helpers[name] = require(path.join(__dirname, helper));
|
|
});
|
|
|
|
module.exports = helpers;
|