gulpfile.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use strict';
  2. var gulp = require('gulp');
  3. var runSequence = require('run-sequence');
  4. var spawn = require('child_process').spawn;
  5. var tslint = require('gulp-tslint');
  6. var runSpawn = function(done, task, opt_arg) {
  7. var child = spawn(task, opt_arg, {stdio: 'inherit'});
  8. child.on('close', function() {
  9. done();
  10. });
  11. };
  12. gulp.task('built:copy', function() {
  13. return gulp.src(['lib/**/*','!lib/**/*.ts'])
  14. .pipe(gulp.dest('built/lib/'));
  15. });
  16. gulp.task('webdriver:update', function(done) {
  17. runSpawn(done, 'webdriver-manager', ['update']);
  18. });
  19. gulp.task('tslint', function() {
  20. return gulp.src(['lib/**/*.ts', 'spec/**/*.ts']).pipe(tslint()).pipe(tslint.report());
  21. });
  22. gulp.task('format:enforce', () => {
  23. const format = require('gulp-clang-format');
  24. const clangFormat = require('clang-format');
  25. return gulp.src(['lib/**/*.ts', 'spec/**/*.ts']).pipe(
  26. format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
  27. });
  28. gulp.task('format', () => {
  29. const format = require('gulp-clang-format');
  30. const clangFormat = require('clang-format');
  31. return gulp.src(['lib/**/*.ts', 'spec/**/*.ts'], { base: '.' }).pipe(
  32. format.format('file', clangFormat)).pipe(gulp.dest('.'));
  33. });
  34. gulp.task('tsc', function(done) {
  35. runSpawn(done, 'node', ['node_modules/typescript/bin/tsc']);
  36. });
  37. gulp.task('lint', function(done) {
  38. runSequence('tslint', 'format:enforce', done);
  39. });
  40. gulp.task('prepublish', function(done) {
  41. runSequence('lint' ,'tsc', 'built:copy', done);
  42. });
  43. gulp.task('pretest', function(done) {
  44. runSequence(
  45. ['webdriver:update', 'tslint', 'clang'], 'tsc', 'built:copy', done);
  46. });
  47. gulp.task('default', ['prepublish']);
  48. gulp.task('build', ['prepublish']);
  49. gulp.task('test:copy', function(done) {
  50. return gulp.src(['spec/**/*','!spec/**/*.ts'])
  51. .pipe(gulp.dest('built/spec/'));
  52. });