dev.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. const initTask = require( './utils/dev-init' );
  7. const pluginCreateTask = require( './utils/dev-plugin-create' );
  8. const pluginInstallTask = require( './utils/dev-plugin-install' );
  9. const pluginUpdateTask = require( './utils/dev-update' );
  10. const pluginStatusTask = require( './utils/dev-status' );
  11. const boilerplateUpdateTask = require( './utils/dev-boilerplate-update' );
  12. const ckeditor5Path = process.cwd();
  13. module.exports = ( grunt ) => {
  14. const packageJSON = grunt.config.data.pkg;
  15. grunt.registerTask( 'dev-init', function() {
  16. const options = getOptions( this );
  17. initTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
  18. } );
  19. grunt.registerTask( 'dev-plugin-create', function() {
  20. const done = this.async();
  21. const options = getOptions( this );
  22. pluginCreateTask( ckeditor5Path, options, grunt.log.writeln, grunt.log.error )
  23. .then( done )
  24. .catch( ( error ) => done( error ) );
  25. } );
  26. grunt.registerTask( 'dev-plugin-install', function() {
  27. const done = this.async();
  28. const options = getOptions( this );
  29. pluginInstallTask( ckeditor5Path, options, grunt.log.writeln, grunt.log.error )
  30. .then( done )
  31. .catch( ( error ) => done( error ) );
  32. } );
  33. grunt.registerTask( 'dev-update', function() {
  34. const options = getOptions( this );
  35. pluginUpdateTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
  36. } );
  37. grunt.registerTask( 'dev-status', function() {
  38. const options = getOptions( this );
  39. pluginStatusTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
  40. } );
  41. grunt.registerTask( 'dev-boilerplate-update', function() {
  42. const options = getOptions( this );
  43. boilerplateUpdateTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
  44. } );
  45. function getOptions( task ) {
  46. const options = {
  47. workspaceRoot: '..'
  48. };
  49. return task.options( options );
  50. }
  51. };