tasks.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. const gulp = require( 'gulp' );
  7. const minimist = require( 'minimist' );
  8. const exec = require( './tasks/exec' );
  9. const log = require( './utils/log' );
  10. const gutil = require( 'gulp-util' );
  11. // const through = require( 'through2' );
  12. module.exports = ( config ) => {
  13. const ckeditor5Path = process.cwd();
  14. const packageJSON = require( '../../../package.json' );
  15. // Configure logging.
  16. log.configure(
  17. ( msg ) => gutil.log( msg ),
  18. ( msg ) => gutil.log( gutil.colors.red( msg ) )
  19. );
  20. const tasks = {
  21. execOnRepositories() {
  22. // Omit `gulp exec` part of arguments
  23. const options = minimist( process.argv.slice( 3 ), {
  24. boolean: [ 'dry-run' ],
  25. alias: { t: 'task' },
  26. default: {
  27. 'dry-run': false
  28. },
  29. stopEarly: false
  30. } );
  31. let execTask;
  32. try {
  33. execTask = require( `./functions/${ options.task }` );
  34. }
  35. catch ( error ) {
  36. log.err( `Cannot find task ${ options.task }` );
  37. }
  38. if ( execTask ) {
  39. return exec( execTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, options[ 'dry-run' ] );
  40. }
  41. },
  42. register() {
  43. gulp.task( 'exec', tasks.execOnRepositories );
  44. }
  45. };
  46. return tasks;
  47. };