UNPKG

@enplug/scripts

Version:
32 lines (27 loc) 790 B
const createS3Client = require('./createS3Client'); const releaseToS3 = require('./releaseToS3'); /** * Uploads entire contents of localDir directory to an S3 bucket with a prefix, while taking into consideration the * options defined in package.json (pkg). * @param {Object} pkg * @param {string} bucket * @param {string} prefix * @param {string} localDir * @param {boolean=} checkExistingRelease */ function syncDir(pkg, bucket, prefix, localDir, checkExistingRelease) { if (prefix.startsWith('/')) { prefix = prefix.substr(1); } const s3Client = createS3Client(pkg); return s3Client ? releaseToS3( s3Client, localDir, bucket, prefix, checkExistingRelease !== false, ) : Promise.resolve(null); } module.exports = syncDir;