Browse Source

Merge branch 'master' into t/44

Piotrek Koszuliński 10 years ago
parent
commit
262903fd3f
9 changed files with 45 additions and 9 deletions
  1. 3 2
      .jshintrc
  2. 1 0
      dev/.jshintrc
  3. 3 1
      dev/tasks/build/utils.js
  4. 20 0
      dev/tests/build/utils.js
  5. 1 1
      package.json
  6. 4 2
      tests/.jshintrc
  7. 7 0
      tests/_utils/amd.js
  8. 0 3
      tests/_utils/utils.js
  9. 6 0
      tests/utils-tests/amd.js

+ 3 - 2
.jshintrc

@@ -4,10 +4,11 @@
 
 	"immed": true,
 	"latedef": "nofunc",
+	"loopfunc": true,
 	"noarg": true,
 	"nonbsp": true,
 	"undef": true,
 	"unused": true,
-	"varstmt": true,
-	"strict": "global"
+	"strict": "global",
+	"varstmt": true
 }

+ 1 - 0
dev/.jshintrc

@@ -4,6 +4,7 @@
 
 	"immed": true,
 	"latedef": "nofunc",
+	"loopfunc": true,
 	"noarg": true,
 	"nonbsp": true,
 	"undef": true,

+ 3 - 1
dev/tasks/build/utils.js

@@ -191,7 +191,9 @@ require( [ 'tests' ], bender.defer(), function( err ) {
 	 */
 	appendBenderLauncher() {
 		return through( { objectMode: true }, ( file, encoding, callback ) => {
-			file.contents = new Buffer( file.contents.toString() + utils.benderLauncherCode );
+			if ( !file.isNull() ) {
+				file.contents = new Buffer( file.contents.toString() + utils.benderLauncherCode );
+			}
 
 			callback( null, file );
 		} );

+ 20 - 0
dev/tests/build/utils.js

@@ -442,6 +442,26 @@ describe( 'build-utils', () => {
 
 			stream.end();
 		} );
+
+		// #62
+		it( 'does nothing to a null file', ( done ) => {
+			const stream = utils.appendBenderLauncher();
+
+			stream.pipe(
+				utils.noop( ( data ) => {
+					expect( data.contents ).to.equal( null );
+					done();
+				} )
+			);
+
+			stream.write( new Vinyl( {
+				cwd: './',
+				path: 'tests/file.js',
+				contents: null
+			} ) );
+
+			stream.end();
+		} );
 	} );
 
 	describe( 'isTestFile', () => {

+ 1 - 1
package.json

@@ -46,7 +46,7 @@
     "minimist": "^1.2.0",
     "mocha": "^2.2.5",
     "mockery": "^1.4.0",
-    "multipipe": "^0.2.1",
+    "multipipe": "^0.3.0",
     "ncp": "^2.0.0",
     "replace": "^0.3.0",
     "shelljs": "^0",

+ 4 - 2
tests/.jshintrc

@@ -2,15 +2,17 @@
 	"browser": true,
 	"esnext": true,
 
+	"expr": true,
 	"immed": true,
 	"latedef": "nofunc",
+	"loopfunc": true,
 	"noarg": true,
 	"nonbsp": true,
+	"strict": "global",
 	"undef": true,
 	"unused": true,
-	"expr": true,
 	"varstmt": true,
-	"strict": "global",
+
 	"globals": {
 		"after": false,
 		"afterEach": false,

+ 7 - 0
tests/_utils/amd.js

@@ -19,10 +19,17 @@ const utils = {
 	 * * `foo` -> `/ckeditor5/foo/foo.js`
 	 * * `foo/bar` -> `/ckeditor5/foo/bar.js`
 	 *
+	 * If the path is already absolute, then it will be returned without any changes.
+	 *
 	 * @param {String} modulePath The simplified path.
 	 * @returns {String} The real path.
 	 */
 	getModulePath( modulePath ) {
+		// Do nothing – path is already absolute.
+		if ( modulePath.startsWith( '/' ) ) {
+			return modulePath;
+		}
+
 		if ( modulePath.indexOf( '/' ) < 0 ) {
 			modulePath = modulePath + '/' + modulePath;
 		}

+ 0 - 3
tests/_utils/utils.js

@@ -3,9 +3,6 @@
  * For licensing, see LICENSE.md.
  */
 
-/* jshint node: false, browser: true */
-/* globals before, afterEach, sinon */
-
 'use strict';
 
 /**

+ 6 - 0
tests/utils-tests/amd.js

@@ -27,6 +27,12 @@ describe( 'amdTestUtils', () => {
 
 			expect( path ).to.equal( '/ckeditor5/core/editor.js' );
 		} );
+
+		it( 'does not process an absolute path', () => {
+			const path = getModulePath( '/foo/bar/bom.js' );
+
+			expect( path ).to.equal( '/foo/bar/bom.js' );
+		} );
 	} );
 
 	describe( 'define()', () => {