(node, state, stack)
| 95 | // you can’t reference a global file as a file attachment. |
| 96 | ancestor(body, { |
| 97 | CallExpression(node, state, stack) { |
| 98 | const {callee} = node; |
| 99 | if (callee.type !== "Identifier" || !alias.has(callee.name) || !references.has(callee)) return; |
| 100 | const args = node.arguments; |
| 101 | if (args.length !== 1) throw syntaxError("FileAttachment requires a single literal string argument", node, input); |
| 102 | const [arg] = args; |
| 103 | if (!isStringLiteral(arg)) throw syntaxError("FileAttachment requires a single literal string argument", node, input); // prettier-ignore |
| 104 | const fileName = getStringLiteralValue(arg); |
| 105 | const filePath = resolveLocalPath(path, fileName); |
| 106 | if (!filePath) throw syntaxError(`non-local file path: ${fileName}`, node, input); |
| 107 | const parent = stack[stack.length - 2]; |
| 108 | const name = relativePath(path, filePath); |
| 109 | const method = |
| 110 | parent && isMemberExpression(parent) && parent.property.type === "Identifier" |
| 111 | ? parent.property.name === "arquero" && /\.parquet$/i.test(fileName) |
| 112 | ? "arquero-parquet" // FileAttachment("foo.parquet").arquero |
| 113 | : parent.property.name // FileAttachment("foo.csv").csv |
| 114 | : KNOWN_FILE_EXTENSIONS[extname(fileName).toLowerCase()]; // bare FileAttachment("foo.csv") |
| 115 | files.push({node, name, method}); |
| 116 | } |
| 117 | }); |
| 118 | |
| 119 | return files; |
nothing calls this directly
no test coverage detected