Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit fc07270

Browse files
peterlauzpao
authored andcommitted
Handle case where options.settings.views is an array (#109)
If an array of paths is passed, make each a regex clause and concatenate with | operator.
1 parent 3fbbc67 commit fc07270

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ function createEngine(engineOptions) {
3535
// Defer babel registration until the first request so we can grab the view path.
3636
if (!moduleDetectRegEx) {
3737
// Path could contain regexp characters so escape it first.
38-
moduleDetectRegEx = new RegExp('^' + _escaperegexp(options.settings.views));
38+
// options.settings.views could be a single string or an array
39+
moduleDetectRegEx = new RegExp(
40+
[].concat(options.settings.views)
41+
.map(viewPath => '^' + _escaperegexp(viewPath))
42+
.join('|')
43+
);
3944
}
45+
4046
if (engineOptions.transformViews && !registered) {
4147
// Passing a RegExp to Babel results in an issue on Windows so we'll just
4248
// pass the view path.

0 commit comments

Comments
 (0)