Skip to content

Commit

Permalink
fix: call config.get to retrieve settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambie committed Aug 9, 2017
1 parent 3a176e4 commit 8ce5b88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ENGINE = {

module.exports = () => {
const debug = require('debug')('web:templates:pug')
const path = require('path')
const pug = require('pug')
const requireDir = require('require-dir')

Expand Down Expand Up @@ -53,11 +54,14 @@ module.exports = () => {
EnginePug.prototype.initialise = function () {
debug('Pug initialised')

if (this.config.engines &&
this.config.engines.pug &&
this.config.engines.pug.paths && this.config.engines.pug.paths.helpers
const engineConfig = this.config.get('engines')

if (engineConfig &&
engineConfig.pug &&
engineConfig.pug.paths && engineConfig.pug.paths.helpers
) {
this.helperFunctions = requireDir(this.config.engines.pug.paths.helpers, { recurse: true, camelcase: true })
const helperPath = path.join(process.cwd(), engineConfig.pug.paths.helpers)
this.helperFunctions = requireDir(helperPath, { recurse: true, camelcase: true })
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/pug.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Pug.js interface', function () {
const Engine = factory()
const instance = new Engine({
additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]),
config: config.config,
config: config,
pagesPath: path.join(helpers.paths.workspace, 'pages')
})

Expand All @@ -69,7 +69,7 @@ describe('Pug.js interface', function () {
const Engine = factory()
const instance = new Engine({
additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]),
config: config.config,
config: config,
pagesPath: path.join(helpers.paths.workspace, 'pages')
})

Expand All @@ -83,7 +83,7 @@ describe('Pug.js interface', function () {
const Engine = factory()
const instance = new Engine({
additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]),
config: config.config,
config: config,
pagesPath: path.join(helpers.paths.workspace, 'pages')
})

Expand Down Expand Up @@ -129,7 +129,7 @@ describe('Pug.js interface', function () {
const Engine = factory()
const instance = new Engine({
additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]),
config: config.config,
config: config,
pagesPath: path.join(helpers.paths.workspace, 'pages')
})

Expand Down

0 comments on commit 8ce5b88

Please sign in to comment.