Skip to content

Commit 8ce5b88

Browse files
committed
fix: call config.get to retrieve settings
1 parent 3a176e4 commit 8ce5b88

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const ENGINE = {
1212

1313
module.exports = () => {
1414
const debug = require('debug')('web:templates:pug')
15+
const path = require('path')
1516
const pug = require('pug')
1617
const requireDir = require('require-dir')
1718

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

56-
if (this.config.engines &&
57-
this.config.engines.pug &&
58-
this.config.engines.pug.paths && this.config.engines.pug.paths.helpers
57+
const engineConfig = this.config.get('engines')
58+
59+
if (engineConfig &&
60+
engineConfig.pug &&
61+
engineConfig.pug.paths && engineConfig.pug.paths.helpers
5962
) {
60-
this.helperFunctions = requireDir(this.config.engines.pug.paths.helpers, { recurse: true, camelcase: true })
63+
const helperPath = path.join(process.cwd(), engineConfig.pug.paths.helpers)
64+
this.helperFunctions = requireDir(helperPath, { recurse: true, camelcase: true })
6165
}
6266
}
6367

test/pug.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('Pug.js interface', function () {
5252
const Engine = factory()
5353
const instance = new Engine({
5454
additionalTemplates: Object.keys(helpers.additionalTemplates).map(name => helpers.additionalTemplates[name]),
55-
config: config.config,
55+
config: config,
5656
pagesPath: path.join(helpers.paths.workspace, 'pages')
5757
})
5858

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

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

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

0 commit comments

Comments
 (0)