@betterer/betterer
Advanced tools
Comparing version 1.1.2 to 1.2.0
import { BettererConfig, BettererConfigPartial } from './types'; | ||
export declare function config(partialConfig: BettererConfigPartial): void; | ||
export declare function createConfig(partialConfig: BettererConfigPartial): BettererConfig; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createConfig = void 0; | ||
exports.createConfig = exports.config = void 0; | ||
var tslib_1 = require("tslib"); | ||
var path = require("path"); | ||
var utils_1 = require("../utils"); | ||
var DEFAULT_CONFIG_PATH = './.betterer'; | ||
var DEFAULT_RESULTS_PATH = './.betterer.results'; | ||
var baseConfig = {}; | ||
function config(partialConfig) { | ||
baseConfig = partialConfig; | ||
} | ||
exports.config = config; | ||
function createConfig(partialConfig) { | ||
var cwd = partialConfig.cwd || process.cwd(); | ||
var configPaths = toArray(partialConfig.configPaths || [DEFAULT_CONFIG_PATH]).map(function (configPath) { | ||
return path.resolve(cwd, configPath); | ||
}); | ||
var filters = toRegExps(toArray(partialConfig.filters)); | ||
var ignores = toArray(partialConfig.ignores); | ||
var resultsPath = path.resolve(cwd, partialConfig.resultsPath || DEFAULT_RESULTS_PATH); | ||
var update = partialConfig.update || false; | ||
return { | ||
configPaths: configPaths, | ||
filters: filters, | ||
ignores: ignores, | ||
resultsPath: resultsPath, | ||
cwd: cwd, | ||
update: update | ||
var relativeConfig = { | ||
configPaths: toArray(partialConfig.configPaths || baseConfig.configPaths || ['./.betterer']), | ||
resultsPath: partialConfig.resultsPath || baseConfig.resultsPath || './.betterer.results', | ||
filters: toRegExps(toArray(partialConfig.filters || baseConfig.filters)), | ||
ignores: toArray(partialConfig.ignores || baseConfig.ignores), | ||
cwd: partialConfig.cwd || baseConfig.cwd || process.cwd(), | ||
update: partialConfig.update || baseConfig.update || false | ||
}; | ||
var tsconfigPath = partialConfig.tsconfigPath || baseConfig.tsconfigPath; | ||
return tslib_1.__assign(tslib_1.__assign({}, relativeConfig), { configPaths: relativeConfig.configPaths.map(function (configPath) { return path.resolve(relativeConfig.cwd, configPath); }), resultsPath: path.resolve(relativeConfig.cwd, relativeConfig.resultsPath), tsconfigPath: tsconfigPath ? path.resolve(relativeConfig.cwd, tsconfigPath) : null }); | ||
} | ||
@@ -26,0 +24,0 @@ exports.createConfig = createConfig; |
@@ -0,1 +1,2 @@ | ||
export { config } from './config'; | ||
export * from './types'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var config_1 = require("./config"); | ||
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } }); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=public.js.map |
@@ -7,2 +7,3 @@ export declare type BettererConfigPaths = ReadonlyArray<string>; | ||
resultsPath: string; | ||
tsconfigPath: string; | ||
filters: BettererConfigFilters | ReadonlyArray<string> | string; | ||
@@ -16,2 +17,3 @@ ignores: BettererConfigIgnore | string; | ||
resultsPath: string; | ||
tsconfigPath: string | null; | ||
filters: BettererConfigFilters; | ||
@@ -18,0 +20,0 @@ ignores: BettererConfigIgnore; |
@@ -1,2 +0,2 @@ | ||
import { BettererConfig, BettererConfigPartial } from '../config'; | ||
import { BettererConfig } from '../config'; | ||
import { BettererReporters } from '../reporters'; | ||
@@ -8,4 +8,4 @@ import { BettererFilePaths } from '../watcher'; | ||
export declare class BettererContext { | ||
readonly config: BettererConfig; | ||
private _reporters?; | ||
config: BettererConfig; | ||
private _stats; | ||
@@ -16,3 +16,3 @@ private _tests; | ||
private _finish; | ||
constructor(config: BettererConfigPartial, _reporters?: BettererReporters | undefined); | ||
constructor(config: BettererConfig, _reporters?: BettererReporters | undefined); | ||
setup(): Promise<void>; | ||
@@ -19,0 +19,0 @@ tearDown(): void; |
@@ -7,3 +7,2 @@ "use strict"; | ||
var path = require("path"); | ||
var config_1 = require("../config"); | ||
var errors_1 = require("../errors"); | ||
@@ -26,2 +25,3 @@ var results_1 = require("../results"); | ||
var _a, _b, _c; | ||
this.config = config; | ||
this._reporters = _reporters; | ||
@@ -33,3 +33,2 @@ this._stats = null; | ||
this._finish = null; | ||
this.config = config_1.createConfig(config); | ||
(_c = (_b = (_a = this._reporters) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.start) === null || _c === void 0 ? void 0 : _c.call(_b); | ||
@@ -273,2 +272,2 @@ } | ||
exports.BettererContext = BettererContext; | ||
//# sourceMappingURL=context.js.map | ||
//# sourceMappingURL=context.js.map |
@@ -10,16 +10,18 @@ import { BettererConfigPartial } from './config'; | ||
export * from './watcher/public'; | ||
export declare function betterer(config: BettererConfigPartial): Promise<BettererStats>; | ||
export declare function betterer(partialConfig?: BettererConfigPartial): Promise<BettererStats>; | ||
export declare namespace betterer { | ||
var single: (config: Partial<{ | ||
var single: (partialConfig: Partial<{ | ||
configPaths: string | import("./config").BettererConfigPaths; | ||
resultsPath: string; | ||
filters: string | readonly string[] | import("./config").BettererConfigFilters; | ||
tsconfigPath: string; | ||
filters: string | import("./config").BettererConfigFilters | readonly string[]; | ||
ignores: string | import("./config").BettererConfigIgnore; | ||
cwd: string; | ||
update: boolean; | ||
}>, filePath: string) => Promise<BettererRuns>; | ||
var watch: (config: Partial<{ | ||
}> | undefined, filePath: string) => Promise<BettererRuns>; | ||
var watch: (partialConfig?: Partial<{ | ||
configPaths: string | import("./config").BettererConfigPaths; | ||
resultsPath: string; | ||
filters: string | readonly string[] | import("./config").BettererConfigFilters; | ||
tsconfigPath: string; | ||
filters: string | import("./config").BettererConfigFilters | readonly string[]; | ||
ignores: string | import("./config").BettererConfigIgnore; | ||
@@ -26,0 +28,0 @@ cwd: string; |
@@ -6,7 +6,8 @@ "use strict"; | ||
var errors_1 = require("@betterer/errors"); | ||
var config_1 = require("./config"); | ||
var context_1 = require("./context"); | ||
var register_1 = require("./register"); | ||
var reporters_1 = require("./reporters"); | ||
var runner_1 = require("./runner"); | ||
var watcher_1 = require("./watcher"); | ||
var register_1 = require("./register"); | ||
tslib_1.__exportStar(require("./config/public"), exports); | ||
@@ -18,10 +19,10 @@ tslib_1.__exportStar(require("./context/public"), exports); | ||
tslib_1.__exportStar(require("./watcher/public"), exports); | ||
register_1.registerExtensions(); | ||
function betterer(config) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var context, runs, stats, e_1; | ||
function betterer(partialConfig) { | ||
var _this = this; | ||
if (partialConfig === void 0) { partialConfig = {}; } | ||
return runContext(partialConfig, function (config) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var context, runs, stats; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 4, , 5]); | ||
context = new context_1.BettererContext(config, reporters_1.serialReporters); | ||
@@ -39,40 +40,37 @@ return [4 /*yield*/, context.setup()]; | ||
return [2 /*return*/, stats]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
errors_1.logError(e_1); | ||
throw e_1; | ||
case 5: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}); }); | ||
} | ||
exports.betterer = betterer; | ||
betterer.single = function bettererSingle(config, filePath) { | ||
betterer.single = function bettererSingle(partialConfig, filePath) { | ||
if (partialConfig === void 0) { partialConfig = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var context, runs, e_2; | ||
var _this = this; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 3, , 4]); | ||
context = new context_1.BettererContext(config); | ||
return [4 /*yield*/, context.setup()]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, runner_1.parallel(context, [filePath])]; | ||
case 2: | ||
runs = _a.sent(); | ||
context.tearDown(); | ||
return [2 /*return*/, runs]; | ||
case 3: | ||
e_2 = _a.sent(); | ||
errors_1.logError(e_2); | ||
throw e_2; | ||
case 4: return [2 /*return*/]; | ||
} | ||
return [2 /*return*/, runContext(partialConfig, function (config) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var context, runs; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
context = new context_1.BettererContext(config); | ||
return [4 /*yield*/, context.setup()]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, runner_1.parallel(context, [filePath])]; | ||
case 2: | ||
runs = _a.sent(); | ||
context.tearDown(); | ||
return [2 /*return*/, runs]; | ||
} | ||
}); | ||
}); })]; | ||
}); | ||
}); | ||
}; | ||
betterer.watch = function bettererWatch(config) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var context_2, watcher, e_3; | ||
betterer.watch = function bettererWatch(partialConfig) { | ||
var _this = this; | ||
if (partialConfig === void 0) { partialConfig = {}; } | ||
return runContext(partialConfig, function (config) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var context, watcher; | ||
var _this = this; | ||
@@ -82,11 +80,10 @@ return tslib_1.__generator(this, function (_a) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
context_2 = new context_1.BettererContext(config, reporters_1.parallelReporters); | ||
watcher = new watcher_1.BettererWatcher(context_2, function (filePaths) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
context = new context_1.BettererContext(config, reporters_1.parallelReporters); | ||
watcher = new watcher_1.BettererWatcher(context, function (filePaths) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, context_2.setup()]; | ||
case 0: return [4 /*yield*/, context.setup()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, runner_1.parallel(context_2, filePaths)]; | ||
return [2 /*return*/, runner_1.parallel(context, filePaths)]; | ||
} | ||
@@ -99,6 +96,21 @@ }); | ||
return [2 /*return*/, watcher]; | ||
} | ||
}); | ||
}); }); | ||
}; | ||
function runContext(partialConfig, run) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var config, e_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
config = config_1.createConfig(partialConfig); | ||
register_1.registerExtensions(config); | ||
return [4 /*yield*/, run(config)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
e_3 = _a.sent(); | ||
errors_1.logError(e_3); | ||
throw e_3; | ||
e_1 = _a.sent(); | ||
errors_1.logError(e_1); | ||
throw e_1; | ||
case 3: return [2 /*return*/]; | ||
@@ -108,3 +120,3 @@ } | ||
}); | ||
}; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -0,3 +1,5 @@ | ||
import { BettererConfig } from './config'; | ||
export declare const JS_EXTENSION = ".js"; | ||
export declare const RESULTS_EXTENTION = ".results"; | ||
export declare function registerExtensions(): void; | ||
export declare const TS_EXTENSION = ".ts"; | ||
export declare function registerExtensions(config: BettererConfig): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.registerExtensions = exports.RESULTS_EXTENTION = exports.JS_EXTENSION = void 0; | ||
exports.registerExtensions = exports.TS_EXTENSION = exports.RESULTS_EXTENTION = exports.JS_EXTENSION = void 0; | ||
var ts_node_1 = require("ts-node"); | ||
exports.JS_EXTENSION = '.js'; | ||
exports.RESULTS_EXTENTION = '.results'; | ||
function registerExtensions() { | ||
exports.TS_EXTENSION = '.ts'; | ||
var isRegistered = false; | ||
function registerExtensions(config) { | ||
if (isRegistered) { | ||
return; | ||
} | ||
isRegistered = true; | ||
// Need to do this so that webpack doesn't remove it | ||
@@ -13,9 +19,15 @@ // during the extension bundle... | ||
var JS = EXTENSIONS[exports.JS_EXTENSION]; | ||
// Use TS-Node register to allow `.betterer.ts` config files: | ||
ts_node_1.register({ | ||
transpileOnly: true, | ||
compilerOptions: { | ||
module: 'commonjs' | ||
if (!EXTENSIONS[exports.TS_EXTENSION]) { | ||
// Use TS-Node register to allow `.betterer.ts` config files: | ||
var tsRegisterOptions = { | ||
transpileOnly: true, | ||
compilerOptions: { | ||
module: 'commonjs' | ||
} | ||
}; | ||
if (config.tsconfigPath) { | ||
tsRegisterOptions.project = config.tsconfigPath; | ||
} | ||
}); | ||
ts_node_1.register(tsRegisterOptions); | ||
} | ||
// Force `.betterer.results` files to be loaded as JS: | ||
@@ -22,0 +34,0 @@ EXTENSIONS[exports.RESULTS_EXTENTION] = function (m, filePath) { |
{ | ||
"name": "@betterer/betterer", | ||
"description": "Main engine for runing betterer tests", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "publishConfig": { | ||
"@betterer/constraints": "^1.0.2", | ||
"@betterer/errors": "^1.0.2", | ||
"@betterer/errors": "^1.2.0", | ||
"@betterer/logger": "^1.0.2", | ||
@@ -41,3 +41,3 @@ "chokidar": "^3.3.1", | ||
}, | ||
"gitHead": "bb3663bbe9559980d56f5dc2ad0722c7a5b8b792" | ||
"gitHead": "7780911635fc418e46bb4b3f8c60eaf10578b710" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
162283
2421
Updated@betterer/errors@^1.2.0