diff --git a/src/cli/src/templates/utils.ts b/src/cli/src/templates/utils.ts index 8362959..5c254e5 100644 --- a/src/cli/src/templates/utils.ts +++ b/src/cli/src/templates/utils.ts @@ -316,9 +316,15 @@ const pageModelArguments = (path: string[], options : Options) : string => { } } -// Used in place of sophisticated AST parsing -const exposes = (keyword: string) => (elmSourceCode: string): boolean => - new RegExp(`module\\s(\\S)+\\sexposing(\\s)+\\([^\\)]*${keyword}[^\\)]*\\)`, 'm').test(elmSourceCode) +const exposes = (value : string) => (str : string) : boolean => { + const regex = new RegExp('^module\\s+[^\\s]+\\s+exposing\\s+\\(([^)]+)\\)') + const match = (str.match(regex) || [])[1] + if (match) { + return match.split(',').filter(a => a).map(a => a.trim()).includes(value) + } else { + return false + } +} export const exposesModel = exposes('Model') export const exposesMsg = exposes('Msg') @@ -334,4 +340,4 @@ export const isStaticPage = (src : string) => exposesPageFunction(src) export const isStaticView = (src : string) => - exposesViewFunction(src) \ No newline at end of file + exposesViewFunction(src)