Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. 'use strict';
  2.  
  3. var template = 'll-forever',
  4. mailOptions = {
  5. litmus: {
  6. from: ' Foo ',
  7. to: 'lingualeo.runme.spam@previews.emailonacid.com',
  8. subject: 'Test email',
  9. html: 'app/' + template + '/index.html'
  10. }
  11. };
  12.  
  13. // oz@wim.agency
  14. var gulp = require('gulp'),
  15. browserSync = require('browser-sync'),
  16. reload = browserSync.reload,
  17. assemble = require('gulp-assemble'),
  18. nodemailer = require('nodemailer'),
  19. fs = require('fs');
  20.  
  21. var transporter = nodemailer.createTransport({
  22. service: 'Gmail',
  23. auth: {
  24. user: 'slawas@yandex.ru',
  25. pass: 'test'
  26. }
  27. });
  28.  
  29. mailOptions.default = mailOptions.litmus;
  30.  
  31. var options = {
  32. data: 'app/' + template + '/layout/data/*.{json,yml}',
  33. layouts: 'app/' + template + '/layout/',
  34. partials: 'app/' + template + '/includes/*.hbs'
  35. };
  36.  
  37. gulp.task('assemble', function () {
  38. gulp.src('app/' + template + '/pages/*.hbs')
  39. .pipe(assemble(options))
  40. .pipe(gulp.dest('app/' + template +'/'));
  41. });
  42.  
  43.  
  44. gulp.task('serve', ['assemble'], function () {
  45. browserSync({
  46. notify: false,
  47. logPrefix: 'WSK',
  48. server: ['app/'+ template]
  49. });
  50.  
  51. gulp.watch('app/' + template +'/**/*.hbs', ['assemble']);
  52. gulp.watch('app/' + template +'/img/**/*', reload);
  53. gulp.watch('app/' + template +'/*.html', reload);
  54. });
  55.  
  56. gulp.task('pp', ['assemble'], function () {
  57. browserSync({
  58. notify: false,
  59. logPrefix: 'WSK',
  60. server: ['app/' + template]
  61. });
  62.  
  63. gulp.watch('app/' + template +'/**/*.hbs', ['assemble']);
  64.  
  65. });
  66.  
  67. gulp.task('html', function () {
  68. browserSync({
  69. notify: false,
  70. logPrefix: 'WSK',
  71. server: ['app/' + template]
  72. });
  73. });
  74.  
  75. gulp.task('send-test', function () {
  76.  
  77. fs.readFile( mailOptions.default.html, function (err, data) {
  78. if (err) throw err;
  79.  
  80. mailOptions.default.html = data;
  81.  
  82. transporter.sendMail(mailOptions.default, function(error, info){
  83. if(error){
  84. console.log(error);
  85. }else{
  86. console.log('Message sent: ' + info.response);
  87. }
  88. });
  89. });
  90. });
  91.  
  92. gulp.task('default', function () {
  93. gulp.start('html');
  94. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement