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

Method publish

src/cml.js:339–364  ·  view source on GitHub ↗
(opts = {})

Source from the content-addressed store, hash-verified

337 }
338
339 async publish(opts = {}) {
340 const { title = '', md, native, rmWatermark } = opts;
341
342 let mime, uri;
343 if (native) {
344 ({ mime, uri } = await this.getDriver().upload(opts));
345 } else {
346 ({ mime, uri } = await upload(opts));
347 }
348
349 if (!rmWatermark && !native) {
350 const [, type] = mime.split('/');
351 uri = watermarkUri({ uri, type });
352 }
353
354 if (!native) {
355 uri = preventcacheUri({ uri });
356 }
357
358 if (md && mime.match('(image|video)/.*'))
359 return `![](${uri}${title ? ` "${title}"` : ''})`;
360
361 if (md) return `[${title}](${uri})`;
362
363 return uri;
364 }
365
366 async runnerToken() {
367 return await this.getDriver().runnerToken();

Callers 3

visitorMethod · 0.95
cml.e2e.test.jsFile · 0.80
publish.jsFile · 0.80

Calls 5

getDriverMethod · 0.95
uploadFunction · 0.85
watermarkUriFunction · 0.85
preventcacheUriFunction · 0.85
uploadMethod · 0.45

Tested by

no test coverage detected