UNPKG

@curvenote/cli

Version:
20 lines (19 loc) 760 B
import chalk from 'chalk'; import { postToJournals } from '../utils/api.js'; export async function commitUploads(session, data) { session.log.debug(`📦 Committing uploads - ${data.files.length} items`); const resp = await postToJournals(session, `/uploads/commit`, data, { method: 'POST' }); if (resp.ok) { const { message } = (await resp.json()); session.log.info(`🚚 Transfer complete`); session.log.debug(chalk.bold(chalk.green(`\n${message}\n`))); return; } try { session.log.debug(await resp.text()); } catch (e) { session.log.debug('Error received but response has no text.'); } throw new Error(`🤕 Failed to commit uploads: ${resp.status} ${resp.statusText}`); }