package.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. package.js - Build the package
  3. */
  4. import * as spawn from 'child_process'
  5. import * as path from 'path'
  6. import * as gulp from 'gulp'
  7. import * as gulpif from 'gulp-if'
  8. import * as log from 'fancy-log'
  9. import * as gzip from 'gulp-gzip'
  10. import config from 'assist'
  11. function buildPackage(cb) {
  12. let cmd = 'bin/package'
  13. print(`Running: ${cmd} ${config.profile} ...`)
  14. let part = path.basename(global.top)
  15. let settings = config[part]
  16. let pkg = spawn.spawn(cmd, [settings.image, config.owner, config.profile])
  17. pkg.stdout.on('data', data => process.stdout.write(data.toString() + '\n'))
  18. pkg.stderr.on('data', data => process.stdout.write(data.toString() + '\n'))
  19. pkg.on('exit', err => {
  20. if (err) {
  21. throw new Error('Cannot package')
  22. }
  23. cb()
  24. })
  25. }
  26. /*
  27. function compress(cb) {
  28. if (config.profile == 'prod') {
  29. gulp.src(['build/*.js'], {buffer: false})
  30. .pipe(gzip({}))
  31. .pipe(gulp.dest('build'))
  32. }
  33. cb()
  34. } */
  35. export default gulp.parallel(buildPackage)