deploy.s3.js 832 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * React Static Boilerplate
  3. * https://github.com/koistya/react-static-boilerplate
  4. *
  5. * Copyright © 2015-2016 Konstantin Tarkus (@koistya)
  6. *
  7. * This source code is licensed under the MIT license found in the
  8. * LICENSE.txt file in the root directory of this source tree.
  9. */
  10. const s3 = require('s3');
  11. const task = require('./task');
  12. module.exports = task('deploy', () => Promise.resolve()
  13. .then(() => require('./build'))
  14. .then(() => new Promise((resolve, reject) => {
  15. const client = s3.createClient({
  16. s3Options: {
  17. region: 'us-east-1',
  18. sslEnabled: true,
  19. },
  20. });
  21. const uploader = client.uploadDir({
  22. localDir: 'build',
  23. deleteRemoved: true,
  24. s3Params: { Bucket: 'www.example.com' },
  25. });
  26. uploader.on('error', reject);
  27. uploader.on('end', resolve);
  28. }))
  29. );