Skip to content

Commit

Permalink
Assert karmaTypescriptConfig.exclude is an array of strings, #129
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbarke committed Jun 9, 2017
1 parent 67a4e61 commit a6e8377
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dist/shared/configuration.js
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var lodash = require("lodash");
var log4js = require("log4js");
var lodash_1 = require("lodash");
var Configuration = (function () {
Expand Down Expand Up @@ -114,6 +115,7 @@ var Configuration = (function () {
this.exclude = this.karmaTypescriptConfig.exclude;
this.include = this.karmaTypescriptConfig.include;
this.tsconfig = this.karmaTypescriptConfig.tsconfig;
this.assertExclude();
};
Configuration.prototype.configurePreprocessor = function () {
var transformPath = function (filepath) {
Expand Down Expand Up @@ -156,6 +158,20 @@ var Configuration = (function () {
"'frameworks: [\"karma-typescript\"]' to your Karma config");
}
};
Configuration.prototype.assertExclude = function () {
if (this.exclude !== undefined) {
if (!Array.isArray(this.exclude)) {
throw new Error("The option 'karmaTypescriptConfig.exclude' must be an array of strings, got [" +
typeof this.exclude + "]: " + this.exclude);
}
this.exclude.forEach(function (item) {
if (!lodash.isString(item)) {
throw new Error("Expected a string in 'karmaTypescriptConfig.exclude', got [" +
typeof item + "]: " + item);
}
});
}
};
Configuration.prototype.assertDeprecatedOptions = function () {
if (this.bundlerOptions.ignoredModuleNames) {
throw new Error("The option 'karmaTypescriptConfig.bundlerOptions.ignoredModuleNames' has been " +
Expand Down
17 changes: 17 additions & 0 deletions src/shared/configuration.ts
@@ -1,3 +1,4 @@
import * as lodash from "lodash";
import * as log4js from "log4js";

import { ConfigOptions } from "karma";
Expand Down Expand Up @@ -165,6 +166,7 @@ export class Configuration {
this.exclude = this.karmaTypescriptConfig.exclude;
this.include = this.karmaTypescriptConfig.include;
this.tsconfig = this.karmaTypescriptConfig.tsconfig;
this.assertExclude();
}

private configurePreprocessor() {
Expand Down Expand Up @@ -218,6 +220,21 @@ export class Configuration {
}
}

private assertExclude() {
if (this.exclude !== undefined) {
if (!Array.isArray(this.exclude)) {
throw new Error("The option 'karmaTypescriptConfig.exclude' must be an array of strings, got [" +
typeof this.exclude + "]: " + this.exclude);
}
this.exclude.forEach((item) => {
if (!lodash.isString(item)) {
throw new Error("Expected a string in 'karmaTypescriptConfig.exclude', got [" +
typeof item + "]: " + item);
}
});
}
}

private assertDeprecatedOptions() {
if ((<any> this.bundlerOptions).ignoredModuleNames) {
throw new Error("The option 'karmaTypescriptConfig.bundlerOptions.ignoredModuleNames' has been " +
Expand Down

0 comments on commit a6e8377

Please sign in to comment.