Skip to content

Commit

Permalink
fix(custom_helpers): Throw error if option is set but no files are found
Browse files Browse the repository at this point in the history
  • Loading branch information
lupas committed Dec 22, 2020
1 parent 821f5f4 commit 43f48b6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,21 @@ const compileFirestoreRules = async function () {
}

// Add Custom Helper Functions to 2nd position of array
logger(
chalk.magenta.bold("Adding ") +
`custom helper functions from folder: ${config.custom_helpers_folder}`
);
if (config.custom_helpers_folder) {
filesArray = glob
logger(
chalk.magenta.bold("Adding ") +
`custom helper functions from folder: ${config.custom_helpers_folder}`
);
const customHelperFunctions = glob
.sync(`${execPath}/${config.custom_helpers_folder}/**/*.rules`)
.concat(filesArray);
if (customHelperFunctions.length) {
filesArray = customHelperFunctions.concat(filesArray)
} else {
logger(
chalk.red.bold("Warning ") +
`You defined the "custom_helpers_folder" property but we could not find any custom helper functions. Please check if the folder & files exist.`
);
}
}

// Add Helper Functions to 2nd position of array
Expand Down

0 comments on commit 43f48b6

Please sign in to comment.