Skip to content

Commit 43f48b6

Browse files
committed
fix(custom_helpers): Throw error if option is set but no files are found
1 parent 821f5f4 commit 43f48b6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,21 @@ const compileFirestoreRules = async function () {
6868
}
6969

7070
// Add Custom Helper Functions to 2nd position of array
71-
logger(
72-
chalk.magenta.bold("Adding ") +
73-
`custom helper functions from folder: ${config.custom_helpers_folder}`
74-
);
7571
if (config.custom_helpers_folder) {
76-
filesArray = glob
72+
logger(
73+
chalk.magenta.bold("Adding ") +
74+
`custom helper functions from folder: ${config.custom_helpers_folder}`
75+
);
76+
const customHelperFunctions = glob
7777
.sync(`${execPath}/${config.custom_helpers_folder}/**/*.rules`)
78-
.concat(filesArray);
78+
if (customHelperFunctions.length) {
79+
filesArray = customHelperFunctions.concat(filesArray)
80+
} else {
81+
logger(
82+
chalk.red.bold("Warning ") +
83+
`You defined the "custom_helpers_folder" property but we could not find any custom helper functions. Please check if the folder & files exist.`
84+
);
85+
}
7986
}
8087

8188
// Add Helper Functions to 2nd position of array

0 commit comments

Comments
 (0)