Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. /**
  2. * Created by yan on 16-10-28.
  3. */
  4. var gulp = require('gulp');
  5. var sftp = require('gulp-sftp');
  6. var paths = require('./paths');
  7. var browserSync = require('browser-sync');
  8. var $ = require('gulp-load-plugins')();
  9. var config = {
  10. remoteInitPath: '/usr/share/nginx/html/cornerstone_ui',//后面不要跟'/'
  11. host: '192.168.110.185',
  12. user: 'root',
  13. pass: '××××××'
  14. }
  15. /**
  16. * 远程自动复制替换文件
  17. */
  18. gulp.task('remote-upload', function () {
  19.  
  20. gulp.watch('assets/**/*', function (event) {
  21. var msg = [
  22. $.util.colors.magenta(event.path),
  23. 'was',
  24. $.util.colors.cyan(event.type)
  25. ];
  26. $.util.log(msg.join(' '));
  27. return gulp.src(event.path)
  28. .pipe(sftp({
  29. host: config.host,
  30. user: config.user,
  31. pass: config.pass,
  32. remotePath: calDestPath(event.path)
  33. }));
  34. });
  35. });
  36. function calDestPath(src) {
  37. var from = src.indexOf('assets/') + 6;
  38. var end = src.lastIndexOf('/');
  39. return config.remoteInitPath + src.substring(from, end);
  40. }
  41. gulp.task('browser-sync', function () {
  42. browserSync.init({
  43. proxy: "127.0.0.1:3000",
  44. port: 8083,
  45. logLevel: 'debug',
  46. ui: {
  47. port: 8089
  48. }
  49. });
  50. gulp.watch('www/**/*').on("change", function () {
  51. browserSync.reload();
  52. });
  53. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement