Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,29 @@ exports.handler = async function (options) {
const client = await getClient(options)
const console = new Console(process.stderr)

if (options.entities.length === 0 && options.index.length === 0) {
process.stderr.write('Error: No entities specified. Use --entities to specify what to export.\n')
process.exit(1)
}

console.time('Export')
return client
.export(options.format, [...options.entities, ...options.index], options.outputFile)
.then(entities => {
console.timeEnd('Export')

for (const { status, reason } of entities) {
if (status === 'rejected') {
console.error(reason)
}
const rejected = entities.filter(e => e.status === 'rejected')
const fulfilled = entities.filter(e => e.status === 'fulfilled')

for (const { reason } of rejected) {
process.stderr.write(`Error: ${reason.message}\n`)
}

if (rejected.length > 0 && fulfilled.length === 0) {
process.stderr.write(`\nAll exports failed. Please check your format and entity options.\n`)
process.stderr.write(`Note: Some formats like 'atf' may not be available for direct export.\n`)
process.stderr.write(`Try using a different format such as 'ndjson', 'csv', or 'ntriples'.\n`)
process.exit(1)
}
})
}