From 407d1fa8d3de5f43f60a9dd6eb06bcc08b79f1f8 Mon Sep 17 00:00:00 2001 From: Alabbas Alhaj Ali Date: Fri, 14 Sep 2018 11:27:50 +0200 Subject: [PATCH 1/4] :bug: fix TypeError: Path must be a string. Received Array --- src/karma-webpack.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/karma-webpack.js b/src/karma-webpack.js index 232cce6..a81c33f 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -237,7 +237,11 @@ Plugin.prototype.readFile = function(file, callback) { var doRead = function() { if (optionsCount > 1) { async.times(optionsCount, function(idx, callback) { - middleware.fileSystem.readFile(path.join(os.tmpdir(), '_karma_webpack_', String(idx), this.outputs[file]), callback) + if (Array.isArray(this.outputs[file])) { + middleware.fileSystem.readFile(path.join(os.tmpdir(), '_karma_webpack_', String(idx), this.outputs[file][0]), callback); + }else{ + middleware.fileSystem.readFile(path.join(os.tmpdir(), '_karma_webpack_', String(idx), this.outputs[file]), callback); + } }.bind(this), function(err, contents) { if (err) { return callback(err) @@ -254,7 +258,11 @@ Plugin.prototype.readFile = function(file, callback) { }) } else { try { - var fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file])) + if (Array.isArray(this.outputs[file])) { + var fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file][0])); + } else { + var fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file])); + } callback(undefined, fileContents) } catch (e) { @@ -297,7 +305,11 @@ function createPreprocesor(/* config.basePath */ basePath, webpackPlugin) { } var outputPath = webpackPlugin.outputs[normalize(filename)] - file.path = normalize(path.join(basePath, outputPath)) + if( Array.isArray(outputPath)){ + file.path = normalize(path.join(basePath, outputPath[0])); + } else { + file.path = normalize(path.join(basePath, outputPath)); + } done(err, content && content.toString()) }) From 232731d624356329764138484fe37fb225cb6def Mon Sep 17 00:00:00 2001 From: Alabbas Alhaj Ali Date: Fri, 14 Sep 2018 15:23:05 +0200 Subject: [PATCH 2/4] improve code structure --- src/karma-webpack.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/karma-webpack.js b/src/karma-webpack.js index a81c33f..5e64420 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -239,7 +239,7 @@ Plugin.prototype.readFile = function(file, callback) { async.times(optionsCount, function(idx, callback) { if (Array.isArray(this.outputs[file])) { middleware.fileSystem.readFile(path.join(os.tmpdir(), '_karma_webpack_', String(idx), this.outputs[file][0]), callback); - }else{ + } else { middleware.fileSystem.readFile(path.join(os.tmpdir(), '_karma_webpack_', String(idx), this.outputs[file]), callback); } }.bind(this), function(err, contents) { @@ -258,10 +258,12 @@ Plugin.prototype.readFile = function(file, callback) { }) } else { try { + + var fileContents = '' if (Array.isArray(this.outputs[file])) { - var fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file][0])); + fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file][0])); } else { - var fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file])); + fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file])); } callback(undefined, fileContents) From 161ade79ebffc05f82936fc56a031f76d06773d2 Mon Sep 17 00:00:00 2001 From: Alabbas Alhaj Ali Date: Fri, 14 Sep 2018 15:51:04 +0200 Subject: [PATCH 3/4] fix Indent spacing created be text editor --- src/karma-webpack.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/karma-webpack.js b/src/karma-webpack.js index 5e64420..7906ba3 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -257,9 +257,8 @@ Plugin.prototype.readFile = function(file, callback) { callback(null, Buffer.concat(contents)) }) } else { - try { - - var fileContents = '' + try { + var fileContents = '' if (Array.isArray(this.outputs[file])) { fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file][0])); } else { From cb9912a8ba7bc96c8e51597e7c6f984b7963407b Mon Sep 17 00:00:00 2001 From: Alabbas Alhaj Ali Date: Fri, 14 Sep 2018 16:18:04 +0200 Subject: [PATCH 4/4] :) fix code editor off text shift --- src/karma-webpack.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/karma-webpack.js b/src/karma-webpack.js index 7906ba3..8a78db5 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -258,7 +258,7 @@ Plugin.prototype.readFile = function(file, callback) { }) } else { try { - var fileContents = '' + var fileContents = '' if (Array.isArray(this.outputs[file])) { fileContents = middleware.fileSystem.readFileSync(path.join(os.tmpdir(), '_karma_webpack_', this.outputs[file][0])); } else {