gulpfile.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. const path = require('path');
  3. const gulp = require('gulp');
  4. const tsGlobs = ['lib/**/*.ts', '*spec/**/*.ts'];
  5. let runSpawn = (task, args, done) => {
  6. done = done || function() {};
  7. const spawn = require('child_process').spawn;
  8. let child = spawn(task, args, {stdio: 'inherit'});
  9. let running = false;
  10. child.on('close', (code) => {
  11. if (!running) {
  12. running = true;
  13. done(code);
  14. }
  15. });
  16. child.on('error', (err) => {
  17. if (!running) {
  18. console.error('gulp encountered a child error');
  19. running = true;
  20. done(err || 1);
  21. }
  22. });
  23. return child;
  24. };
  25. gulp.task('copy', function() {
  26. return gulp.src(['config.json', 'package.json'])
  27. .pipe(gulp.dest('built/'));
  28. });
  29. gulp.task('format:enforce', () => {
  30. const format = require('gulp-clang-format');
  31. const clangFormat = require('clang-format');
  32. return gulp.src(tsGlobs).pipe(
  33. format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
  34. });
  35. gulp.task('format', () => {
  36. const format = require('gulp-clang-format');
  37. const clangFormat = require('clang-format');
  38. return gulp.src(tsGlobs, { base: '.' }).pipe(
  39. format.format('file', clangFormat)).pipe(gulp.dest('.'));
  40. });