Skip to content

Commit

Permalink
fix(order-export): Fix handling promises during order export. Remove …
Browse files Browse the repository at this point in the history
…csvFile parameter.
  • Loading branch information
junajan committed Jul 27, 2017
1 parent 69f218c commit 9e99166
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/coffee/run.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,11 @@ utils.ensureCredentials(argv)
.then (outputDir) =>
logger.debug "Created output dir at #{outputDir}"
@outputDir = outputDir
fileName = utils.getFileName argv.fileWithTimestamp, 'orders'
csvFile = "#{@outputDir}/#{fileName}"
if argv.exportCSVAsStream
logger.info "Exporting orders as stream."
fileName = utils.getFileName argv.fileWithTimestamp, 'orders'
csvFile = argv.csvFile or "#{@outputDir}/#{fileName}"
exportCSVAsStream(csvFile, orderExport)

else
orderExport.run()
.then (data) =>
Expand All @@ -142,8 +141,6 @@ utils.ensureCredentials(argv)
# - one file for each order
@orderReferences = []
if exportType.toLowerCase() is 'csv'
fileName = utils.getFileName argv.fileWithTimestamp, 'orders'
csvFile = argv.csvFile or "#{@outputDir}/#{fileName}"
logger.info "Storing CSV export to '#{csvFile}'."
@orderReferences.push fileName: csvFile, entry: data
fs.writeFileAsync csvFile, data
Expand Down Expand Up @@ -249,8 +246,6 @@ utils.ensureCredentials(argv)
.catch (error) =>
logger.error error, 'Oops, something went wrong!'
@exitCode = 1
.done()
.catch (err) =>
logger.error err, 'Problems on getting client credentials from config files.'
@exitCode = 1
.done()

0 comments on commit 9e99166

Please sign in to comment.