瀏覽代碼

Loading files in Bender is trickyyyy...

Piotrek Koszuliński 10 年之前
父節點
當前提交
5dbcaa723d
共有 1 個文件被更改,包括 23 次插入3 次删除
  1. 23 3
      dev/bender/plugins/ckeditor5/static/extensions.js

+ 23 - 3
dev/bender/plugins/ckeditor5/static/extensions.js

@@ -9,13 +9,29 @@
 'use strict';
 
 ( () => {
-	const basePath = bender.config.applications.ckeditor.basePath;
-
 	/**
 	 * AMD tools related to CKEditor.
 	 */
 	bender.amd = {
 		getModulePath( name ) {
+			let appBasePath = bender.basePath;
+			let ckeditorBasePath = bender.config.applications.ckeditor.basePath;
+			let moduleBasePath;
+
+			// Ugh... make some paths cleanup, because we need to combine these fragments and we don't want to
+			// duplicate '/'. BTW. if you want to touch this make sure you haven't broken Bender jobs which
+			// have different bender.basePaths (no trailing '/', unnecessary 'tests/' fragment).
+			moduleBasePath =
+				appBasePath
+					.split( '/' )
+					.filter( nonEmpty )
+					// When running a job we need to drop the last parth of the base path, which is "tests".
+					.slice( 0, -1 )
+					.concat(
+						ckeditorBasePath.split( '/' ).filter( nonEmpty )
+					)
+					.join( '/' );
+
 			if ( name != 'ckeditor' ) {
 				// Resolve shortened feature names to `featureName/featureName`.
 				if ( name.indexOf( '/' ) < 0 ) {
@@ -29,7 +45,7 @@
 				}
 			}
 
-			return basePath + name + '.js';
+			return '/' + moduleBasePath + '/' + name + '.js';
 		},
 
 		define( name, deps, body ) {
@@ -76,4 +92,8 @@
 			return modules;
 		}
 	};
+
+	function nonEmpty( str ) {
+		return !!str.length;
+	}
 } )();