gulpfile.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. require('coffee-script/register');
  2. const gulp = require('gulp'),
  3. umd = require('gulp-umd'),
  4. path = require('path'),
  5. concat = require('gulp-concat'),
  6. insert = require('gulp-insert'),
  7. mocha = require('gulp-mocha'),
  8. babel = require('gulp-babel'),
  9. replace = require('gulp-replace'),
  10. uglify = require('gulp-uglify'),
  11. runSequence = require('run-sequence'),
  12. argv = require('yargs').argv;
  13. const onlyTest = argv.onlyTest || argv.limitTest;
  14. const SQUEL_VERSION = require('./package.json').version;
  15. gulp.task('build-basic', function() {
  16. return gulp.src([
  17. './src/core.js',
  18. ])
  19. .pipe( concat('squel-basic.js') )
  20. .pipe( replace(/<<VERSION_STRING>>/i, SQUEL_VERSION) )
  21. .pipe( babel({
  22. presets: ['es2015']
  23. }) )
  24. .pipe( umd({
  25. exports: function (file) {
  26. return 'squel';
  27. },
  28. namespace: function(file) {
  29. return 'squel';
  30. }
  31. }))
  32. .pipe( gulp.dest('./dist') )
  33. .pipe( uglify() )
  34. .pipe( insert.prepend('/*! squel | https://github.com/hiddentao/squel | BSD license */') )
  35. .pipe( concat('squel-basic.min.js') )
  36. .pipe( gulp.dest('./dist') )
  37. });
  38. gulp.task('build-full', function() {
  39. return gulp.src([
  40. './src/core.js',
  41. './src/mssql.js',
  42. './src/mysql.js',
  43. './src/postgres.js',
  44. ])
  45. .pipe( concat('squel.js') )
  46. .pipe( replace(/<<VERSION_STRING>>/i, SQUEL_VERSION) )
  47. .pipe( babel({
  48. presets: ['es2015']
  49. }) )
  50. .pipe( umd({
  51. exports: function (file) {
  52. return 'squel';
  53. },
  54. namespace: function(file) {
  55. return 'squel';
  56. }
  57. }))
  58. .pipe( gulp.dest('./dist') )
  59. .pipe( uglify() )
  60. .pipe( insert.prepend('/*! squel | https://github.com/hiddentao/squel | BSD license */') )
  61. .pipe( concat('squel.min.js') )
  62. .pipe( gulp.dest('./dist') )
  63. });
  64. gulp.task('build', ['build-basic', 'build-full']);
  65. gulp.task('test', function () {
  66. return gulp.src(onlyTest || [
  67. './test/baseclasses.test.coffee',
  68. './test/blocks.test.coffee',
  69. './test/case.test.coffee',
  70. './test/custom.test.coffee',
  71. './test/delete.test.coffee',
  72. './test/expressions.test.coffee',
  73. './test/insert.test.coffee',
  74. './test/select.test.coffee',
  75. './test/update.test.coffee',
  76. './test/mssql.test.coffee',
  77. './test/mysql.test.coffee',
  78. './test/postgres.test.coffee',
  79. ], { read: false })
  80. .pipe(mocha({
  81. ui: 'exports',
  82. reporter: 'spec',
  83. }))
  84. ;
  85. });
  86. gulp.task('default', function(cb) {
  87. runSequence(['build'], 'test', cb);
  88. });