gulpfile.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. 'use strict';
  6. // Increase max listeners for event emitters
  7. require('events').EventEmitter.defaultMaxListeners = 100;
  8. const gulp = require('gulp');
  9. const util = require('./build/lib/util');
  10. const path = require('path');
  11. const compilation = require('./build/lib/compilation');
  12. // Fast compile for development time
  13. gulp.task('clean-client', util.rimraf('out'));
  14. gulp.task('compile-client', ['clean-client'], compilation.compileTask('out', false));
  15. gulp.task('watch-client', ['clean-client'], compilation.watchTask('out', false));
  16. // Full compile, including nls and inline sources in sourcemaps, for build
  17. gulp.task('clean-client-build', util.rimraf('out-build'));
  18. gulp.task('compile-client-build', ['clean-client-build'], compilation.compileTask('out-build', true));
  19. gulp.task('watch-client-build', ['clean-client-build'], compilation.watchTask('out-build', true));
  20. // Default
  21. gulp.task('default', ['compile']);
  22. // All
  23. gulp.task('clean', ['clean-client', 'clean-extensions']);
  24. gulp.task('compile', ['compile-client', 'compile-extensions']);
  25. gulp.task('watch', ['watch-client', 'watch-extensions']);
  26. // All Build
  27. gulp.task('clean-build', ['clean-client-build', 'clean-extensions-build']);
  28. gulp.task('compile-build', ['compile-client-build', 'compile-extensions-build']);
  29. gulp.task('watch-build', ['watch-client-build', 'watch-extensions-build']);
  30. var ALL_EDITOR_TASKS = [
  31. // Always defined tasks
  32. 'clean-client',
  33. 'compile-client',
  34. 'watch-client',
  35. 'clean-client-build',
  36. 'compile-client-build',
  37. 'watch-client-build',
  38. // Editor tasks (defined in gulpfile.editor)
  39. 'clean-optimized-editor',
  40. 'optimize-editor',
  41. 'clean-minified-editor',
  42. 'minify-editor',
  43. 'clean-editor-distro',
  44. 'editor-distro',
  45. 'analyze-editor-distro',
  46. // hygiene tasks
  47. 'tslint',
  48. 'hygiene',
  49. ];
  50. var runningEditorTasks = process.argv.length > 2 && process.argv.slice(2).every(function (arg) { return (ALL_EDITOR_TASKS.indexOf(arg) !== -1); });
  51. process.on('unhandledRejection', (reason, p) => {
  52. console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
  53. process.exit(1);
  54. });
  55. if (runningEditorTasks) {
  56. require(`./build/gulpfile.editor`);
  57. require(`./build/gulpfile.hygiene`);
  58. } else {
  59. // Load all the gulpfiles only if running tasks other than the editor tasks
  60. const build = path.join(__dirname, 'build');
  61. require('glob').sync('gulpfile.*.js', { cwd: build })
  62. .forEach(f => require(`./build/${f}`));
  63. }