( source: string, filename: string, parseScriptFn: ScriptParseFn )
| 92 | } |
| 93 | |
| 94 | export function parseFile( |
| 95 | source: string, |
| 96 | filename: string, |
| 97 | parseScriptFn: ScriptParseFn |
| 98 | ): void { |
| 99 | const {descriptor, errors} = parse(source, { |
| 100 | filename, |
| 101 | }) |
| 102 | if (errors.length) { |
| 103 | throw errors[0] |
| 104 | } |
| 105 | const {script, scriptSetup, template} = descriptor |
| 106 | |
| 107 | if (template) { |
| 108 | walk(template.ast, templateSimpleExpressionNodeVisitor(parseScriptFn)) |
| 109 | } |
| 110 | |
| 111 | if (script) { |
| 112 | parseScriptFn(script.content) |
| 113 | } |
| 114 | |
| 115 | if (scriptSetup) { |
| 116 | parseScriptFn(scriptSetup.content) |
| 117 | } |
| 118 | } |
no test coverage detected