Advertisement
Guest User

Untitled

a guest
Jan 20th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. var config = require('./config');
  2. var gulp = require('gulp');
  3. var browserSync = require('browser-sync').create();
  4. var browserify = require('browserify');
  5. var plumber = require('gulp-plumber');
  6. var sass = require('gulp-sass');
  7. var source = require('vinyl-source-stream');
  8. var bowerSrc = require('gulp-bower-src');
  9. var htmlReplace = require('gulp-html-replace');
  10. var replace = require('gulp-replace');
  11. var gulpFilter = require('gulp-filter');
  12. var DiffDeployer = require('ftp-diff-deployer');
  13. var mandrill = require('node-mandrill')(config.mandrill.apiKey);
  14. var runSequence = require('run-sequence');
  15.  
  16. gulp.task('sass', function () {
  17. return gulp.src('src/sass/**/*.scss')
  18. .pipe(plumber())
  19. .pipe(sass())
  20. .pipe(gulp.dest('./app/css'));
  21. });
  22.  
  23. gulp.task('watch', function () {
  24. gulp.watch('./src/js/**/*.js', ['browserify']);
  25. gulp.watch('./src/sass/**/*.scss', ['sass']);
  26. gulp.watch('./app/css/*.css', ['reload']);
  27. gulp.watch("./app/index.html", ['reload']);
  28. gulp.watch("./app/js/**/*.js", ['reload']);
  29. });
  30.  
  31. gulp.task('browserify', function () {
  32. return browserify('./src/js/app.js')
  33. .bundle()
  34. .pipe(source('bundle.js'))
  35. .pipe(gulp.dest('./app/js'));
  36. });
  37.  
  38. gulp.task('reload', function () {
  39. browserSync.reload();
  40. });
  41.  
  42. gulp.task('serve', ['watch'], function () {
  43.  
  44. browserSync.init({
  45. server: {
  46. baseDir: "./app",
  47. routes: {
  48. "/bower_components": "./bower_components"
  49. }
  50. }
  51. });
  52.  
  53. });
  54.  
  55. // build
  56. gulp.task('build', ['bowerSrc'], function() {
  57. gulp.src('./app/**/*')
  58. .pipe(gulp.dest('./build'));
  59. });
  60.  
  61. gulp.task('bowerSrc', function () {
  62. bowerSrc()
  63. .pipe(gulp.dest('./build/bower_components'));
  64. });
  65.  
  66. gulp.task('deploy', ['build'], function () {
  67.  
  68. var deployer = new DiffDeployer({
  69. host: '216.70.112.70',
  70. auth: {
  71. username: config.ftp.username,
  72. password: config.ftp.password
  73. },
  74. src: 'app',
  75. dest: '/clv4',
  76. memory: 'ftp-diff-deployer-memory-file.json',
  77. exclude: ['node_modules']
  78. });
  79.  
  80. deployer.deploy(function (err) {
  81. if (err) {
  82. console.error('Something went wrong!');
  83. console.error(err);
  84. } else {
  85. console.log('Everything went fine!');
  86. runSequence('sendEmailNotification');
  87. }
  88. });
  89.  
  90. });
  91.  
  92. gulp.task('sendEmailNotification', function () {
  93.  
  94. var sendEmail = function () {
  95.  
  96. //send an e-mail
  97. mandrill('/messages/send', {
  98.  
  99. message: {
  100. to: config.email_notification.to,
  101. from_name: config.email_notification.from_name,
  102. from_email: config.email_notification.from_email,
  103. subject: config.email_notification.subject,
  104. html: config.email_notification.html
  105. }
  106.  
  107. }, function (error, response) {
  108.  
  109. // error
  110. if (error) {
  111.  
  112. console.log( JSON.stringify(error) );
  113.  
  114. } else {
  115.  
  116. console.log('Email notification sent!');
  117.  
  118. }
  119.  
  120. });
  121.  
  122. };
  123.  
  124. sendEmail();
  125.  
  126. });
  127.  
  128. gulp.task('default', ['serve']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement