aashish1111

Untitled

Feb 12th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. import * as gulp from 'gulp'
  2. import {buildBundle} from './tools/gulp/build'
  3. import watch from './tools/gulp/watch'
  4. import lint from './tools/gulp/lint'
  5. import release from './tools/gulp/release'
  6.  
  7. const cdnUploader = require('cdn-uploader')
  8. export const logError = (stream) => {
  9. return stream.on('error', function(err: any) {
  10. console.error(err)
  11. this.emit('end')
  12. })
  13. }
  14. const distDir = [
  15. [
  16. './dist/**/*.js',
  17. './dist/**/*.css'
  18. ],
  19. [
  20. './dist/**/*.png',
  21. './dist/**/*.jpg'
  22. ],
  23. [
  24. './dist/**/*.ttf',
  25. './dist/**/*.svg',
  26. './dist/**/*.woff',
  27. './dist/**/*.eof'
  28. ]
  29. ]
  30.  
  31. const CDNs = [
  32. {
  33. host: 'v0.ftp.upyun.com',
  34. user: 'teambition/dn-st',
  35. password: process.env.CDN_UPYUN_PWD
  36. },
  37. {
  38. host: 'ftp.keycdn.com',
  39. user: 'teambition',
  40. password: process.env.CDN_UPYUN_PWD
  41. }
  42. ]
  43.  
  44. const cdnUpload = (env: string, target: string) => {
  45. const config = require(`./config/${env}.json`)
  46. distDir.forEach((path: string []) => {
  47. gulp.src(path)
  48. .pipe(cdnUploader(config.cdnNames[target], CDNs))
  49. })
  50. }
  51.  
  52. gulp.task('lint', () => {
  53. return lint()
  54. })
  55.  
  56. gulp.task('watch.wechat', () => {
  57. return watch('default', 'wechat')
  58. })
  59.  
  60. gulp.task('watch.ding', () => {
  61. return watch('default', 'ding')
  62. })
  63.  
  64. gulp.task('watch.qqgroup', () => {
  65. return watch('default', 'qqgroup')
  66. })
  67.  
  68. gulp.task('wechat', async function () {
  69. return await buildBundle('default', 'wechat')
  70. })
  71.  
  72. gulp.task('wechat.beta', async function () {
  73. return await buildBundle('beta', 'wechat')
  74. })
  75.  
  76. gulp.task('wechat.release', async function() {
  77. return await release('release', 'wechat')
  78. })
  79.  
  80. gulp.task('qqgroup', async function () {
  81. return await buildBundle('default', 'qqgroup')
  82. })
  83.  
  84. gulp.task('qqgroup.beta', async function () {
  85. return await buildBundle('beta', 'qqgroup')
  86. })
  87.  
  88. gulp.task('qqgroup.beta.deploy', async function () {
  89. await release('beta', 'qqgroup')
  90. cdnUpload('beta', 'qqgroup')
  91. })
  92.  
  93. gulp.task('qqgroup.release', async function() {
  94. return await release('release', 'qqgroup')
  95. })
  96.  
  97. gulp.task('ding', async function () {
  98. return await buildBundle('default', 'ding')
  99. })
  100.  
  101. gulp.task('ding.beta', async function () {
  102. return await buildBundle('beta', 'ding')
  103. })
  104.  
  105. gulp.task('ding.release', async function() {
  106. return await release('release', 'ding')
  107. })
  108.  
  109. gulp.task('deploy.wechat', async function () {
  110. const config = require('./config/release.json')
  111. await release('release', 'wechat')
  112. cdnUpload('release', 'wechat')
  113. })
  114.  
  115. gulp.task('deploy.qqgroup', async function () {
  116. const config = require('./config/release.json')
  117. await release('release', 'qqgroup')
  118. cdnUpload('release', 'qqgroup')
  119. })
  120.  
  121. gulp.task('deploy.ding', async function () {
  122. const config = require('./config/release.json')
  123. await release('release', 'ding')
  124. cdnUpload('release', 'ding')
  125. })
Add Comment
Please, Sign In to add comment