Browse Source

Let's not require the extension, to align the config format to what PluginCollection accepts.

Piotrek Koszuliński 9 years ago
parent
commit
9494de6d5e
3 changed files with 29 additions and 23 deletions
  1. 10 6
      dev/tasks/bundle/tasks.js
  2. 6 4
      dev/tasks/bundle/utils.js
  3. 13 13
      dev/tests/bundle/utils.js

+ 10 - 6
dev/tasks/bundle/tasks.js

@@ -44,21 +44,25 @@ module.exports = ( config ) => {
 		 *			// Name of CKEditor instance exposed as global variable by a bundle.
 		 *			moduleName: 'MyCKEditor',
 		 *
-		 *			// Path to specified editor.
-		 *			// It could be a path relative to `build/esnext/ckeditor5` directory e.g. `classic-editor/classic.js`
-		 *			// or path relative to directory where build task will be executed `./full/path/to/custom/editor.js`.
-		 *			editor: 'classic-editor/classic.js',
+		 *			// Path to specified editor module.
+		 *			// It could be a path relative to `build/esnext/ckeditor5` directory e.g. `classic-editor/classic`
+		 *			// or path relative to directory where build task will be executed `./full/path/to/custom/editor`.
+		 *			//
+		 *			// Note: file extension is appended automatically.
+		 *			editor: 'classic-editor/classic',
 		 *
 		 *			// List of features.
+		 *			//
+		 *			// Note: file extension is appended automatically.
 		 *			features: [
 		 *				// It could be a plugin name only if plugin is a default CKEditor plugin.
 		 *				'delete',
 		 *
 		 *				// It could be a path relative to `build/esnext/ckeditor5` directory.
-		 *				`typing/typing.js`
+		 *				`typing/typing`,
 		 *
 		 *				// Or it could be a path relative to directory where build task will be executed.
-		 *				'./path/to/some/custom/feature.js',
+		 *				'./path/to/some/custom/feature',
 		 *			]
 		 *		};
 		 *

+ 6 - 4
dev/tasks/bundle/utils.js

@@ -36,15 +36,17 @@ const utils = {
 	 * When module path is not relative then treat this path as a path to the one of the ckeditor5 default module
 	 * (relative to ./bundle/exnext/ckeditor5) and add prefix `./build/esnext/ckeditor5/` to this path.
 	 *
-	 * @param {String} modulePath Path the ckeditor5 module.
+	 * This method also adds `.js` extension.
+	 *
+	 * @param {String} modulePath Path to the module (without extension).
 	 */
 	getFullPath( modulePath ) {
 		// If path is not a relative path (no leading ./ or ../).
 		if ( modulePath.charAt( 0 ) != '.' ) {
-			return `./${ path.join( 'build/esnext/ckeditor5', modulePath ) }`;
+			return `./${ path.join( 'build/esnext/ckeditor5', modulePath ) }.js`;
 		}
 
-		return modulePath;
+		return modulePath + '.js';
 	},
 
 	/**
@@ -59,7 +61,7 @@ const utils = {
 			return utils.getFullPath( name );
 		}
 
-		return utils.getFullPath( `${ name }/${ name }.js` );
+		return utils.getFullPath( `${ name }/${ name }` );
 	},
 
 	/**

+ 13 - 13
dev/tests/bundle/utils.js

@@ -33,12 +33,12 @@ describe( 'bundle-utils', () => {
 
 	describe( 'getFullPath', () => {
 		it( 'should return full path when passed path not relative', () => {
-			expect( utils.getFullPath( 'editor-classic/classic.js' ) ).to.equal( './build/esnext/ckeditor5/editor-classic/classic.js' );
+			expect( utils.getFullPath( 'editor-classic/classic' ) ).to.equal( './build/esnext/ckeditor5/editor-classic/classic.js' );
 		} );
 
 		it( 'should return unmodified path when passed path is a relative', () => {
-			expect( utils.getFullPath( './path/to/editor-classic/classic.js' ) ).to.equal( './path/to/editor-classic/classic.js' );
-			expect( utils.getFullPath( '../path/to/editor-classic/classic.js' ) ).to.equal( '../path/to/editor-classic/classic.js' );
+			expect( utils.getFullPath( './path/to/editor-classic/classic' ) ).to.equal( './path/to/editor-classic/classic.js' );
+			expect( utils.getFullPath( '../path/to/editor-classic/classic' ) ).to.equal( '../path/to/editor-classic/classic.js' );
 		} );
 	} );
 
@@ -48,12 +48,12 @@ describe( 'bundle-utils', () => {
 		} );
 
 		it( 'should return full path if passed argument is a relative path', () => {
-			expect( utils.getPluginPath( 'typing/typing.js' ) ).to.equal( './build/esnext/ckeditor5/typing/typing.js' );
+			expect( utils.getPluginPath( 'typing/typing' ) ).to.equal( './build/esnext/ckeditor5/typing/typing.js' );
 		} );
 
 		it( 'should return unmodified plugin path if passed argument is a relative path', () => {
-			expect( utils.getPluginPath( './typing.js' ) ).to.equal( './typing.js' );
-			expect( utils.getPluginPath( '../typing.js' ) ).to.equal( '../typing.js' );
+			expect( utils.getPluginPath( './typing' ) ).to.equal( './typing.js' );
+			expect( utils.getPluginPath( '../typing' ) ).to.equal( '../typing.js' );
 		} );
 	} );
 
@@ -68,11 +68,11 @@ describe( 'bundle-utils', () => {
 		it( 'should render file content with proper data', () => {
 			const result = utils.renderEntryFileContent( './bundle/tmp', {
 				moduleName: 'MyCKEditor',
-				editor: 'editor-classic/classic.js',
+				editor: 'editor-classic/classic',
 				features: [
 					'delete',
-					'path/to/default.js',
-					'./path/to/custom.js'
+					'path/to/default',
+					'./path/to/custom'
 				]
 			} );
 
@@ -107,11 +107,11 @@ export default class MyCKEditor extends Classic {
 		it( 'should render file content with unique plugin names', () => {
 			const result = utils.renderEntryFileContent( './bundle/tmp', {
 				moduleName: 'MyCKEditor',
-				editor: 'editor-classic/classic.js',
+				editor: 'editor-classic/classic',
 				features: [
 					'plugin',
-					'path/to/plugin.js',
-					'other/path/to/plugin.js'
+					'path/to/plugin',
+					'other/path/to/plugin'
 				]
 			} );
 
@@ -146,7 +146,7 @@ export default class MyCKEditor extends Classic {
 		it( 'should render file content with proper without features', () => {
 			const result = utils.renderEntryFileContent( './bundle/tmp', {
 				moduleName: 'MyCKEditor',
-				editor: 'editor-classic/classic.js'
+				editor: 'editor-classic/classic'
 			} );
 
 			const expected = `