MCPcopy
hub / github.com/iterative/cml / visitor

Method visitor

src/cml.js:223–261  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

221 return node.title && node.title.startsWith('CML watermark');
222 };
223 const visitor = async (node) => {
224 if (node.url && !isWatermark(node)) {
225 // Check for embedded images from dvclive
226 if (node.url.startsWith('data:image/')) {
227 logger.debug(
228 `found already embedded image, head: ${node.url.slice(0, 25)}`
229 );
230 const encodedData = node.url.slice(node.url.indexOf(',') + 1);
231 const mimeType = node.url.slice(
232 node.url.indexOf(':') + 1,
233 node.url.indexOf(';')
234 );
235 const data = Buffer.from(encodedData, 'base64');
236 node.url = await this.publish({
237 ...opts,
238 mimeType: mimeType,
239 buffer: data,
240 url: publishUrl
241 });
242 } else {
243 const absolutePath = path.resolve(
244 path.dirname(markdownFile),
245 node.url
246 );
247 if (!triggerFile && watch) watcher.add(absolutePath);
248 try {
249 node.url = await this.publish({
250 ...opts,
251 path: absolutePath,
252 url: publishUrl
253 });
254 } catch (err) {
255 if (err.code === 'ENOENT')
256 logger.debug(`file not found: ${node.url} (${absolutePath})`);
257 else throw err;
258 }
259 }
260 }
261 };
262
263 await Promise.all(nodes.map(visitor));
264 };

Callers

nothing calls this directly

Calls 1

publishMethod · 0.95

Tested by

no test coverage detected