Skip to content

Commit

Permalink
Fix to validate nunjucksPaths as a string
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Mar 5, 2024
1 parent 8f229fd commit 5e534e7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/plugins/plugin-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ function checkNunjucksMacroExists (executionPath, nunjucksFileName, nunjucksPath
// set up a flag for the existance of a nunjucks path
let nunjucksPathExists = false

if (nunjucksPaths === undefined) {
// Check if the nunjucksMacros are at the root level of the project
if (fse.existsSync(path.join(executionPath, nunjucksFileName))) nunjucksPathExists = true
if (!nunjucksPaths || typeof nunjucksPaths === 'string') {
const pathToCheck = typeof nunjucksPaths === 'string'
? path.join(executionPath, nunjucksPaths, nunjucksFileName)
: path.join(executionPath, nunjucksFileName) // root level

// Check if the nunjucksMacros are at a single path in the project
if (fse.existsSync(pathToCheck)) nunjucksPathExists = true
} else {
// Combine the file path name for each nunjucks path and check if any one of them exists
for (const nunjucksPath of nunjucksPaths) {
Expand Down

0 comments on commit 5e534e7

Please sign in to comment.