@nestia/e2e
Advanced tools
Comparing version 0.2.3 to 0.3.0
@@ -68,2 +68,8 @@ /** | ||
showElapsedTime?: boolean; | ||
/** | ||
* Extension of dynamic functions. | ||
* | ||
* @default js | ||
*/ | ||
extension?: string; | ||
} | ||
@@ -70,0 +76,0 @@ /** |
@@ -167,4 +167,5 @@ "use strict"; | ||
var report, executor, iterator; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -177,6 +178,6 @@ report = { | ||
executor = execute(options)(report)(assert); | ||
iterator = iterate(executor); | ||
iterator = iterate((_a = options.extension) !== null && _a !== void 0 ? _a : "js")(executor); | ||
return [4 /*yield*/, iterator(path)]; | ||
case 1: | ||
_a.sent(); | ||
_b.sent(); | ||
report.time = Date.now() - report.time; | ||
@@ -189,59 +190,61 @@ return [2 /*return*/, report]; | ||
}; | ||
var iterate = function (executor) { | ||
var visitor = function (path) { return __awaiter(_this, void 0, void 0, function () { | ||
var directory, directory_1, directory_1_1, file, location_1, stats, modulo, e_1_1; | ||
var e_1, _a; | ||
return __generator(this, function (_b) { | ||
var _c; | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, fs_1.default.promises.readdir(path)]; | ||
case 1: | ||
directory = _b.sent(); | ||
_b.label = 2; | ||
case 2: | ||
_b.trys.push([2, 12, 13, 14]); | ||
directory_1 = __values(directory), directory_1_1 = directory_1.next(); | ||
_b.label = 3; | ||
case 3: | ||
if (!!directory_1_1.done) return [3 /*break*/, 11]; | ||
file = directory_1_1.value; | ||
location_1 = path_1.default.resolve("".concat(path, "/").concat(file)); | ||
return [4 /*yield*/, fs_1.default.promises.lstat(location_1)]; | ||
case 4: | ||
stats = _b.sent(); | ||
if (!(stats.isDirectory() === true)) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, visitor(location_1)]; | ||
case 5: | ||
_b.sent(); | ||
return [3 /*break*/, 10]; | ||
case 6: | ||
if (file.substr(-3) !== ".".concat(EXTENSION)) | ||
var iterate = function (extension) { | ||
return function (executor) { | ||
var visitor = function (path) { return __awaiter(_this, void 0, void 0, function () { | ||
var directory, directory_1, directory_1_1, file, location_1, stats, modulo, e_1_1; | ||
var e_1, _a; | ||
return __generator(this, function (_b) { | ||
var _c; | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, fs_1.default.promises.readdir(path)]; | ||
case 1: | ||
directory = _b.sent(); | ||
_b.label = 2; | ||
case 2: | ||
_b.trys.push([2, 12, 13, 14]); | ||
directory_1 = __values(directory), directory_1_1 = directory_1.next(); | ||
_b.label = 3; | ||
case 3: | ||
if (!!directory_1_1.done) return [3 /*break*/, 11]; | ||
file = directory_1_1.value; | ||
location_1 = path_1.default.resolve("".concat(path, "/").concat(file)); | ||
return [4 /*yield*/, fs_1.default.promises.lstat(location_1)]; | ||
case 4: | ||
stats = _b.sent(); | ||
if (!(stats.isDirectory() === true)) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, visitor(location_1)]; | ||
case 5: | ||
_b.sent(); | ||
return [3 /*break*/, 10]; | ||
_b.label = 7; | ||
case 7: return [4 /*yield*/, (_c = location_1, Promise.resolve().then(function () { return __importStar(require(_c)); }))]; | ||
case 8: | ||
modulo = _b.sent(); | ||
return [4 /*yield*/, executor(location_1, modulo)]; | ||
case 9: | ||
_b.sent(); | ||
_b.label = 10; | ||
case 10: | ||
directory_1_1 = directory_1.next(); | ||
return [3 /*break*/, 3]; | ||
case 11: return [3 /*break*/, 14]; | ||
case 12: | ||
e_1_1 = _b.sent(); | ||
e_1 = { error: e_1_1 }; | ||
return [3 /*break*/, 14]; | ||
case 13: | ||
try { | ||
if (directory_1_1 && !directory_1_1.done && (_a = directory_1.return)) _a.call(directory_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
return [7 /*endfinally*/]; | ||
case 14: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
return visitor; | ||
case 6: | ||
if (file.substr(-3) !== ".".concat(extension)) | ||
return [3 /*break*/, 10]; | ||
_b.label = 7; | ||
case 7: return [4 /*yield*/, (_c = location_1, Promise.resolve().then(function () { return __importStar(require(_c)); }))]; | ||
case 8: | ||
modulo = _b.sent(); | ||
return [4 /*yield*/, executor(location_1, modulo)]; | ||
case 9: | ||
_b.sent(); | ||
_b.label = 10; | ||
case 10: | ||
directory_1_1 = directory_1.next(); | ||
return [3 /*break*/, 3]; | ||
case 11: return [3 /*break*/, 14]; | ||
case 12: | ||
e_1_1 = _b.sent(); | ||
e_1 = { error: e_1_1 }; | ||
return [3 /*break*/, 14]; | ||
case 13: | ||
try { | ||
if (directory_1_1 && !directory_1_1.done && (_a = directory_1.return)) _a.call(directory_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
return [7 /*endfinally*/]; | ||
case 14: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
return visitor; | ||
}; | ||
}; | ||
@@ -353,4 +356,3 @@ var execute = function (options) { | ||
}; | ||
var EXTENSION = __filename.substring(__filename.length - 2); | ||
})(DynamicExecutor = exports.DynamicExecutor || (exports.DynamicExecutor = {})); | ||
//# sourceMappingURL=DynamicExecutor.js.map |
{ | ||
"name": "@nestia/e2e", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "E2E test utilify functions", | ||
@@ -31,3 +31,3 @@ "main": "lib/index.js", | ||
}, | ||
"homepage": "https://github.com/samchon/nestia#readme", | ||
"homepage": "https://nestia.io", | ||
"devDependencies": { | ||
@@ -34,0 +34,0 @@ "@trivago/prettier-plugin-sort-imports": "^4.0.0", |
@@ -82,2 +82,9 @@ import chalk from "chalk"; | ||
showElapsedTime?: boolean; | ||
/** | ||
* Extension of dynamic functions. | ||
* | ||
* @default js | ||
*/ | ||
extension?: string; | ||
} | ||
@@ -183,3 +190,3 @@ | ||
const executor = execute(options)(report)(assert); | ||
const iterator = iterate(executor); | ||
const iterator = iterate(options.extension ?? "js")(executor); | ||
await iterator(path); | ||
@@ -191,22 +198,29 @@ | ||
const iterate = <Arguments extends any[]>( | ||
executor: (path: string, modulo: Module<Arguments>) => Promise<void>, | ||
) => { | ||
const visitor = async (path: string): Promise<void> => { | ||
const directory: string[] = await fs.promises.readdir(path); | ||
for (const file of directory) { | ||
const location: string = NodePath.resolve(`${path}/${file}`); | ||
const stats: fs.Stats = await fs.promises.lstat(location); | ||
const iterate = | ||
(extension: string) => | ||
<Arguments extends any[]>( | ||
executor: ( | ||
path: string, | ||
modulo: Module<Arguments>, | ||
) => Promise<void>, | ||
) => { | ||
const visitor = async (path: string): Promise<void> => { | ||
const directory: string[] = await fs.promises.readdir(path); | ||
for (const file of directory) { | ||
const location: string = NodePath.resolve( | ||
`${path}/${file}`, | ||
); | ||
const stats: fs.Stats = await fs.promises.lstat(location); | ||
if (stats.isDirectory() === true) { | ||
await visitor(location); | ||
continue; | ||
} else if (file.substr(-3) !== `.${EXTENSION}`) continue; | ||
if (stats.isDirectory() === true) { | ||
await visitor(location); | ||
continue; | ||
} else if (file.substr(-3) !== `.${extension}`) continue; | ||
const modulo: Module<Arguments> = await import(location); | ||
await executor(location, modulo); | ||
} | ||
const modulo: Module<Arguments> = await import(location); | ||
await executor(location, modulo); | ||
} | ||
}; | ||
return visitor; | ||
}; | ||
return visitor; | ||
}; | ||
@@ -269,3 +283,2 @@ const execute = | ||
} | ||
const EXTENSION: string = __filename.substring(__filename.length - 2); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136373
2683