(code: string)
| 19 | } |
| 20 | |
| 21 | function getProgramPath(code: string): NodePath<t.Program> { |
| 22 | const ast = parseAst({ code }) |
| 23 | let programPath: NodePath<t.Program> | undefined |
| 24 | |
| 25 | babel.traverse(ast, { |
| 26 | Program(path: NodePath<t.Program>) { |
| 27 | programPath = path |
| 28 | path.stop() |
| 29 | }, |
| 30 | }) |
| 31 | |
| 32 | if (!programPath) { |
| 33 | throw new Error('Program path not found') |
| 34 | } |
| 35 | |
| 36 | return programPath |
| 37 | } |
| 38 | |
| 39 | describe('normalizePath', () => { |
| 40 | it('should convert Windows backslashes to forward slashes', () => { |