Skip to content

Commit

Permalink
feat(results): add result table of actually imported entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Rötsch authored and axe312ger committed Oct 19, 2017
1 parent 6fd0f20 commit 914d171
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,30 @@ export default function runContentfulImport (params) {
return tasks.run({
data: {}
})
.then((response) => {
.then((ctx) => {
console.log('Finished importing all data')

const resultTypes = Object.keys(ctx.data)
if (resultTypes.length) {
const resultTable = new Table()

resultTable.push([{colSpan: 2, content: 'Imported entities'}])

resultTypes.forEach((type) => {
resultTable.push([startCase(type), ctx.data[type].length])
})

console.log(resultTable.toString())
} else {
console.log('No data was imported')
}

const durationHuman = options.startTime.fromNow(true)
const durationSeconds = moment().diff(options.startTime, 'seconds')

console.log(`The import took ${durationHuman} (${durationSeconds}s)`)

return response
return ctx.data
})
.catch((err) => {
log.push({
Expand Down

0 comments on commit 914d171

Please sign in to comment.