const uploadDir = require('./uploadDir');
const checkForExistingRelease = require('./checkForExistingRelease');

function releaseToS3(s3Client, localDir, bucket, prefix) {
  return checkForExistingRelease(s3Client, bucket, prefix).then(function () {
    return uploadDir(s3Client, localDir, bucket, prefix)
      .catch(function (error) {
        console.error('There was an error during the release process!');
        console.error(error.stack);
        return null;
      })
      .then(function (result) {
        if (result == null) {
          return;
        }
        console.log('Release finished');
      });
    }, () => {  });
}
module.exports = releaseToS3;