dev.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 ckeditor5Path = process.cwd();
  11. module.exports = ( grunt ) => {
  12. const packageJSON = grunt.config.data.pkg;
  13. grunt.registerTask( 'dev-init', function() {
  14. const options = getOptions( this );
  15. initTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
  16. } );
  17. grunt.registerTask( 'dev-plugin-create', function() {
  18. const done = this.async();
  19. const options = getOptions( this );
  20. pluginCreateTask( ckeditor5Path, options, grunt.log.writeln, grunt.log.error ).then( done );
  21. } );
  22. grunt.registerTask( 'dev-plugin-install', function() {
  23. const done = this.async();
  24. const options = getOptions( this );
  25. pluginInstallTask( ckeditor5Path, options, grunt.log.writeln, grunt.log.error ).then( done );
  26. } );
  27. grunt.registerTask( 'dev-update', function() {
  28. const options = getOptions( this );
  29. pluginUpdateTask( ckeditor5Path, packageJSON, options, grunt.log.writeln, grunt.log.error );
  30. } );
  31. function getOptions( context ) {
  32. const options = {
  33. workspaceRoot: '..'
  34. };
  35. return context.options( options );
  36. }
  37. };