docs: function upload ({ body, s3bucket, cloudfront, outfile }) {
    const bucketUrl = `https://s3.amazonaws.com/${s3bucket}`
    return new Promise((resolve, reject) => {
      const s3object = new AWS.S3({
        params: {
          ACL: 'public-read',
          Body: body,
          Bucket: s3bucket,
          ContentType: mime.getType(outfile),
          Key: outfile
        }
      })
  
      const bytes = bytesToSize(body.byteLength || body.length)
      const bucketLink = `<${bucketUrl}/${outfile}|${s3bucket}/${outfile}>`
      s3object.upload().send(function (err) {
        if (err) {
          return reject(
            new Error(
              `s3 upload to ${bucketLink} rejected with ${err.code} ${
                err.message
              }`
            )
          )
        }
        if (cloudfront) {
          const cf = new AWS.CloudFront()
          logger
            .log(`:lightning: *cloudfront:* invalidating path ${outfile}`)
            .then(() => {
              cf.createInvalidation(
                {
                  DistributionId: cloudfront,
                  InvalidationBatch: {
                    CallerReference: uuid.v4(),
                    Paths: {
                      Items: ['/' + outfile],
                      Quantity: 1
                    }
                  }
                },
                function (err) {
                  if (err) {
                    return reject(
                      new Error(`cf invalidation rejected with ${err.message}`)
                    )
                  }
                  done()
                }
              )
            })
        } else {
          done()
        }
      })
  
      /**
       * Helper function to log a successful upload to s3.
       */
      function done () {
        logger
          .log(`:checkered_flag: *uploaded:* ${bucketLink} (${bytes})`)
          .then(resolve)
      }
    })
  }