UNPKG

@enplug/scripts

Version:
23 lines (19 loc) 673 B
const chalk = require('chalk'); function uploadTranslationToS3(s3, bucket, remotePath, translation) { let normalizedPath = remotePath.replace(/\\/g, '/'); if (normalizedPath[0] === '/') { normalizedPath = normalizedPath.slice(1); } return new Promise((resolve, reject) => s3.upload({ Bucket: bucket, Key: normalizedPath, Body: translation, ContentType: 'application/json' }, (err, data) => { if (err) { reject(err); } else { console.log(`${chalk.green.bold('Translations uploaded to S3')} ${chalk.yellow.bold(`[${bucket}/${normalizedPath}]`)}`); resolve(data); } })); } module.exports = { uploadTranslationToS3 };