index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 path = require( 'path' );
  7. const files = [
  8. path.join( __dirname, '../static/extensions.js' ),
  9. path.join( __dirname, '../static/tools.js' )
  10. ];
  11. module.exports = {
  12. name: 'bender-ckeditor5',
  13. attach() {
  14. this.plugins.addFiles( files );
  15. this.on( 'test:created', ( test ) => {
  16. const moduleRegExp = /node_modules\/ckeditor5-([^\/]+)/;
  17. let name = test.displayName;
  18. let module = name.match( moduleRegExp );
  19. if ( module ) {
  20. test.tags.unshift( 'module!' + module[ 1 ] );
  21. test.displayName = name.replace( moduleRegExp, '$1: ' );
  22. } else {
  23. test.tags.unshift( 'module!ckeditor5' );
  24. test.displayName = 'ckeditor5: ' + test.displayName;
  25. }
  26. } );
  27. // Add this plugins' scripts before the includes pagebuilder (which handles bender-include directives), so
  28. // the main tools file is loaded before tools included in the core or in the plugins.
  29. this.pagebuilders.add( 'ckeditor5', build, this.pagebuilders.getPriority( 'includes' ) - 1 );
  30. function build( data ) {
  31. files.forEach( ( file ) => {
  32. data.addJS( path.join( '/plugins/', file ).split( path.sep ).join( '/' ) );
  33. } );
  34. return data;
  35. }
  36. }
  37. };