Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

poku

Package Overview
Dependencies
Maintainers
0
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poku - npm Package Compare versions

Comparing version 1.23.0 to 2.0.0

lib/modules/essentials/strict.d.ts

2

lib/@types/describe.d.ts

@@ -8,4 +8,2 @@ import type { backgroundColor } from '../services/format.js';

icon?: string;
/** @deprecated */
pad?: boolean;
};

@@ -8,4 +8,2 @@ export type Control = {

status: boolean;
assert?: boolean;
test?: boolean;
cb?: () => unknown | Promise<unknown>;

@@ -15,4 +13,2 @@ };

immediate?: boolean;
test?: boolean;
assert?: boolean;
};

@@ -17,20 +17,2 @@ import type { Configs as ListFilesConfigs } from './list-files.js';

/**
* @deprecated
* Customize `stdout` options.
*/
log?: {
/**
* @deprecated
*
* @default false
*/
success?: boolean;
/**
* @deprecated
*
* @default true
*/
fail?: boolean;
};
/**
* This option overwrites all `log` settings.

@@ -37,0 +19,0 @@ *

@@ -8,4 +8,2 @@ "use strict";

cb: undefined,
assert: false,
test: true,
},

@@ -15,5 +13,3 @@ after: {

cb: undefined,
assert: false,
test: true,
},
};

@@ -1,30 +0,32 @@

import type { ProcessAssertionOptions } from '../../@types/assert.js';
import * as nodeAssert from 'node:assert';
declare function doesNotThrow(block: () => unknown, message?: string | ProcessAssertionOptions['message']): void;
declare function doesNotThrow(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ProcessAssertionOptions['message']): void;
declare function throws(block: () => unknown, message?: ProcessAssertionOptions['message']): void;
declare function throws(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ProcessAssertionOptions['message']): void;
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: ProcessAssertionOptions['message']): Promise<void>;
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: ProcessAssertionOptions['message']): Promise<void>;
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: ProcessAssertionOptions['message']): Promise<void>;
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: ProcessAssertionOptions['message']): Promise<void>;
export declare const assert: ((value: unknown, message?: ProcessAssertionOptions["message"]) => void) & {
ok: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
equal: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
deepEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
strictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
deepStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
doesNotMatch: (value: string, regExp: RegExp, message?: ProcessAssertionOptions["message"]) => void;
doesNotReject: typeof doesNotReject;
throws: typeof throws;
doesNotThrow: typeof doesNotThrow;
notEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notDeepEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notDeepStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
match: (value: string, regExp: RegExp, message?: ProcessAssertionOptions["message"]) => void;
ifError: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
fail: (message?: ProcessAssertionOptions["message"]) => never;
rejects: typeof rejects;
import nodeAssert from 'node:assert';
export declare const assert: ((value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void) & {
ok: (value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
equal: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
deepEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
strictEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
deepStrictEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
doesNotMatch: (value: string, regExp: RegExp, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
doesNotReject: {
(block: (() => Promise<unknown>) | Promise<unknown>, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
};
throws: {
(block: () => unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
(block: () => unknown, error: nodeAssert.AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
};
doesNotThrow: {
(block: () => unknown, message?: string | import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
(block: () => unknown, error: nodeAssert.AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
};
notEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
notDeepEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
notStrictEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
notDeepStrictEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
match: (value: string, regExp: RegExp, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
ifError: (value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
fail: (message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => never;
rejects: {
(block: (() => Promise<unknown>) | Promise<unknown>, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
};
};
export {};
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.assert = void 0;
const nodeAssert = __importStar(require("assert"));
/* c8 ignore next */ // ?
const node_assert_1 = __importDefault(require("assert"));
const assert_js_1 = require("../../services/assert.js");
const get_runtime_js_1 = require("../../parsers/get-runtime.js");
const ok = (value, message) => {
(0, assert_js_1.processAssert)(() => {
nodeAssert.ok(value);
}, { message });
};
const equal = (actual, expected, message) => {
(0, assert_js_1.processAssert)(() => {
nodeAssert.equal(actual, expected);
}, { message });
};
const deepEqual = (actual, expected, message) => {
(0, assert_js_1.processAssert)(() => nodeAssert.deepEqual(actual, expected), { message });
};
const strictEqual = (actual, expected, message) => {
(0, assert_js_1.processAssert)(() => nodeAssert.strictEqual(actual, expected), { message });
};
const deepStrictEqual = (actual, expected, message) => {
(0, assert_js_1.processAssert)(() => nodeAssert.deepStrictEqual(actual, expected), {
message,
});
};
const notEqual = (actual, expected, message) => {
(0, assert_js_1.processAssert)(() => nodeAssert.notEqual(actual, expected), {
message,
});
};
const notDeepEqual = (actual, expected, message) => {
(0, assert_js_1.processAssert)(() => nodeAssert.notDeepEqual(actual, expected), { message });
};
const notStrictEqual = (actual, expected, message) => {
(0, assert_js_1.processAssert)(() => nodeAssert.notStrictEqual(actual, expected), {
message,
});
};
const notDeepStrictEqual = (actual, expected, message) => {
(0, assert_js_1.processAssert)(() => nodeAssert.notDeepStrictEqual(actual, expected), {
message,
});
};
const ifError = (value, message) => {
(0, assert_js_1.processAssert)(() => {
nodeAssert.ifError(value);
}, {
message,
defaultMessage: 'Expected no error, but received an error',
hideDiff: true,
throw: true,
});
};
/* c8 ignore start */
const fail = (message) => {
(0, assert_js_1.processAssert)(() => {
nodeAssert.fail(message);
}, {
message,
defaultMessage: 'Test failed intentionally',
hideDiff: true,
});
process.exit(1);
};
function doesNotThrow(block, errorOrMessage, message) {
(0, assert_js_1.processAssert)(() => {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
nodeAssert.doesNotThrow(block, errorOrMessage, message);
}
else {
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
nodeAssert.doesNotThrow(block, msg);
}
}, {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Expected function not to throw',
hideDiff: true,
throw: true,
});
}
function throws(block, errorOrMessage, message) {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
(0, assert_js_1.processAssert)(() => nodeAssert.throws(block, errorOrMessage), {
message,
defaultMessage: 'Expected function to throw',
hideDiff: true,
});
}
else {
const msg = typeof errorOrMessage !== 'undefined' ? errorOrMessage : message;
(0, assert_js_1.processAssert)(() => nodeAssert.throws(block, message), {
message: msg,
defaultMessage: 'Expected function to throw',
hideDiff: true,
});
}
}
function rejects(block, errorOrMessage, message) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, assert_js_1.processAssert)(() => __awaiter(this, void 0, void 0, function* () {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
yield nodeAssert.rejects(block, errorOrMessage, message);
}
else {
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
yield nodeAssert.rejects(block, msg);
}
}), {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Expected promise to be rejected with specified error',
hideDiff: true,
throw: true,
});
});
}
function doesNotReject(block, errorOrMessage, message) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, assert_js_1.processAssert)(() => __awaiter(this, void 0, void 0, function* () {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
yield nodeAssert.doesNotReject(block, errorOrMessage, message);
}
else {
yield nodeAssert.doesNotReject(block, message);
}
}), {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Got unwanted rejection',
hideDiff: true,
throw: true,
});
});
}
const match = (value, regExp, message) => {
/* c8 ignore next 3 */
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12) {
throw new Error('match is available from Node.js 12 or higher');
}
(0, assert_js_1.processAssert)(() => nodeAssert === null || nodeAssert === void 0 ? void 0 : nodeAssert.match(value, regExp), {
message,
actual: 'Value',
expected: 'RegExp',
defaultMessage: 'Value should match regExp',
});
};
const doesNotMatch = (value, regExp, message) => {
/* c8 ignore next 3 */
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12) {
throw new Error('doesNotMatch is available from Node.js 12 or higher');
}
(0, assert_js_1.processAssert)(() => nodeAssert.doesNotMatch(value, regExp), {
message,
actual: 'Value',
expected: 'RegExp',
defaultMessage: 'Value should not match regExp',
});
};
exports.assert = Object.assign((value, message) => ok(value, message), {
ok,
equal,
deepEqual,
strictEqual,
deepStrictEqual,
doesNotMatch,
doesNotReject,
throws,
doesNotThrow,
notEqual,
notDeepEqual,
notStrictEqual,
notDeepStrictEqual,
match,
ifError,
fail,
rejects,
}
/* c8 ignore next */ // ?
);
exports.assert = (0, assert_js_1.createAssert)(node_assert_1.default);
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -32,79 +23,77 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

node_process_1.default.once('SIGINT', exports.onSigint);
function poku(targetPaths, configs) {
return __awaiter(this, void 0, void 0, function* () {
let code = 0;
files_js_1.finalResults.started = new Date();
const start = node_process_1.default.hrtime();
const prepareDirs = Array.prototype.concat(targetPaths);
/* c8 ignore next */ // TODO: Allow users to pass cwd for monorepo improvements
const dirs = prepareDirs.length > 0 ? prepareDirs : ['.'];
const showLogs = !(0, output_js_1.isQuiet)(configs);
// Sequential
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
for (const dir of dirs) {
const result = yield (0, run_tests_js_1.runTests)(dir, configs);
/* c8 ignore next 6 */
if (!result) {
code = 1;
if (configs === null || configs === void 0 ? void 0 : configs.failFast) {
break;
}
async function poku(targetPaths, configs) {
let code = 0;
files_js_1.finalResults.started = new Date();
const start = node_process_1.default.hrtime();
const prepareDirs = Array.prototype.concat(targetPaths);
/* c8 ignore next */ // TODO: Allow users to pass cwd for monorepo improvements
const dirs = prepareDirs.length > 0 ? prepareDirs : ['.'];
const showLogs = !(0, output_js_1.isQuiet)(configs);
// Sequential
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
for (const dir of dirs) {
const result = await (0, run_tests_js_1.runTests)(dir, configs);
/* c8 ignore next 6 */
if (!result) {
code = 1;
if (configs === null || configs === void 0 ? void 0 : configs.failFast) {
break;
}
}
if (configs === null || configs === void 0 ? void 0 : configs.noExit) {
return code;
}
const end = node_process_1.default.hrtime(start);
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
files_js_1.finalResults.time = total;
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
return;
}
// Parallel
if (showLogs) {
write_js_1.Write.hr();
/* c8 ignore next */ // ?
write_js_1.Write.log(`${(0, format_js_1.format)('Running the Test Suite in Parallel').bold()}\n`);
if (configs === null || configs === void 0 ? void 0 : configs.noExit) {
return code;
}
try {
const promises = dirs.map((dir) => __awaiter(this, void 0, void 0, function* () {
const result = yield (0, run_tests_js_1.runTestsParallel)(dir, configs);
/* c8 ignore next 3 */
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast)) {
throw new Error('quiet');
}
return result;
}));
const concurrency = yield Promise.all(promises);
const end = node_process_1.default.hrtime(start);
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
files_js_1.finalResults.time = total;
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
return;
}
// Parallel
if (showLogs) {
write_js_1.Write.hr();
/* c8 ignore next */ // ?
write_js_1.Write.log(`${(0, format_js_1.format)('Running the Test Suite in Parallel').bold()}\n`);
}
try {
const promises = dirs.map(async (dir) => {
const result = await (0, run_tests_js_1.runTestsParallel)(dir, configs);
/* c8 ignore next 3 */
if (concurrency.some((result) => !result)) {
code = 1;
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast)) {
throw new Error('quiet');
}
/* c8 ignore next */
return result;
});
const concurrency = await Promise.all(promises);
/* c8 ignore next 3 */
if (concurrency.some((result) => !result)) {
code = 1;
}
catch (_a) {
}
finally {
const end = node_process_1.default.hrtime(start);
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
files_js_1.finalResults.time = total;
}
showLogs && write_js_1.Write.hr();
if (showLogs && files_js_1.fileResults.success.size > 0) {
write_js_1.Write.log(Array.from(files_js_1.fileResults.success)
.map(([file, time]) => `${indentation_js_1.indentation.test}${(0, format_js_1.format)('โœ”').success()} ${(0, format_js_1.format)(`${file} ${(0, format_js_1.format)(`โ€บ ${time}ms`).success()}`).dim()}`)
.join('\n'));
}
/* c8 ignore start */
if (showLogs && files_js_1.fileResults.fail.size > 0) {
write_js_1.Write.log(Array.from(files_js_1.fileResults.fail)
.map(([file, time]) => `${indentation_js_1.indentation.test}${(0, format_js_1.format)('โœ˜').fail()} ${(0, format_js_1.format)(`${file} ${(0, format_js_1.format)(`โ€บ ${time}ms`).fail()}`).dim()}`)
.join('\n'));
}
/* c8 ignore stop */
if (configs === null || configs === void 0 ? void 0 : configs.noExit) {
return code;
}
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
});
/* c8 ignore next */
}
catch (_a) {
}
finally {
const end = node_process_1.default.hrtime(start);
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
files_js_1.finalResults.time = total;
}
showLogs && write_js_1.Write.hr();
if (showLogs && files_js_1.fileResults.success.size > 0) {
write_js_1.Write.log(Array.from(files_js_1.fileResults.success)
.map(([file, time]) => `${indentation_js_1.indentation.test}${(0, format_js_1.format)('โœ”').success()} ${(0, format_js_1.format)(`${file} ${(0, format_js_1.format)(`โ€บ ${time}ms`).success()}`).dim()}`)
.join('\n'));
}
/* c8 ignore start */
if (showLogs && files_js_1.fileResults.fail.size > 0) {
write_js_1.Write.log(Array.from(files_js_1.fileResults.fail)
.map(([file, time]) => `${indentation_js_1.indentation.test}${(0, format_js_1.format)('โœ˜').fail()} ${(0, format_js_1.format)(`${file} ${(0, format_js_1.format)(`โ€บ ${time}ms`).fail()}`).dim()}`)
.join('\n'));
}
/* c8 ignore stop */
if (configs === null || configs === void 0 ? void 0 : configs.noExit) {
return code;
}
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -31,3 +22,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

timeout: options === null || options === void 0 ? void 0 : options.timeout,
/* c8 ignore next 4 */
cwd: (options === null || options === void 0 ? void 0 : options.cwd) ? (0, list_files_js_1.sanitizePath)((0, node_path_1.normalize)(options.cwd)) : undefined,

@@ -40,3 +30,2 @@ shell: get_runner_js_1.isWindows,

let portBackup;
/* c8 ignore start */
const end = (port) => new Promise((resolve) => {

@@ -57,7 +46,7 @@ try {

if (port && ['bun', 'deno'].includes(runtime)) {
setTimeout(() => __awaiter(void 0, void 0, void 0, function* () {
yield kill_js_1.kill.port(port);
setTimeout(async () => {
await kill_js_1.kill.port(port);
resolve(undefined);
return;
}));
});
}

@@ -74,3 +63,2 @@ else {

});
/* c8 ignore stop */
runningProcesses.set(PID, { end, port: portBackup });

@@ -88,6 +76,4 @@ service.stdout.on('data', (data) => {

}
/* c8 ignore next */
(options === null || options === void 0 ? void 0 : options.verbose) && write_js_1.Write.log(data);
});
/* c8 ignore start */
service.stderr.on('data', (data) => {

@@ -110,3 +96,2 @@ if (!isResolved && typeof (options === null || options === void 0 ? void 0 : options.startAfter) !== 'number') {

});
/* c8 ignore stop */
service.on('close', (code) => {

@@ -117,3 +102,2 @@ if (code !== 0) {

});
/* c8 ignore start */
const timeout = setTimeout(() => {

@@ -125,3 +109,2 @@ if (!isResolved) {

}, (options === null || options === void 0 ? void 0 : options.timeout) || 60000);
/* c8 ignore stop */
if (typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'number') {

@@ -136,3 +119,2 @@ setTimeout(() => {

}
/* c8 ignore next */
}

@@ -142,8 +124,8 @@ catch (_a) { }

/** Starts a file in a background process (useful for servers, APIs, etc.) */
const startService = (file, options) => __awaiter(void 0, void 0, void 0, function* () {
const startService = async (file, options) => {
const runtimeOptions = (0, get_runner_js_1.runner)(file, { platform: options === null || options === void 0 ? void 0 : options.platform });
const runtime = runtimeOptions.shift();
const runtimeArgs = [...runtimeOptions, file];
return yield backgroundProcess(runtime, runtimeArgs, (0, node_path_1.normalize)((0, list_files_js_1.sanitizePath)(file)), options);
});
return await backgroundProcess(runtime, runtimeArgs, (0, node_path_1.normalize)((0, list_files_js_1.sanitizePath)(file)), options);
};
exports.startService = startService;

@@ -158,4 +140,3 @@ /**

*/
const startScript = (script, options) => __awaiter(void 0, void 0, void 0, function* () {
/* c8 ignore next */
const startScript = async (script, options) => {
const runner = (options === null || options === void 0 ? void 0 : options.runner) || 'npm';

@@ -165,10 +146,12 @@ const runtimeOptions = (0, get_runner_js_1.scriptRunner)(runner);

const runtimeArgs = [...runtimeOptions, script];
return yield backgroundProcess(runtime, runtimeArgs, script, Object.assign(Object.assign({}, options), { runner }));
});
return await backgroundProcess(runtime, runtimeArgs, script, {
...options,
runner,
});
};
exports.startScript = startScript;
/* c8 ignore start */ // Process
node_process_1.default.once('SIGINT', () => __awaiter(void 0, void 0, void 0, function* () {
node_process_1.default.once('SIGINT', async () => {
for (const { end, port } of runningProcesses.values()) {
yield end(port);
await end(port);
}
}));
});
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,50 +9,48 @@ exports.describe = describe;

/* c8 ignore next */ // ?
function describe(arg1, arg2) {
return __awaiter(this, void 0, void 0, function* () {
let title;
let cb;
let options;
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
if (typeof arg1 === 'string') {
title = arg1;
if (typeof arg2 === 'function') {
cb = arg2;
}
else {
options = arg2;
}
async function describe(arg1, arg2) {
let title;
let cb;
let options;
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
if (typeof arg1 === 'string') {
title = arg1;
if (typeof arg2 === 'function') {
cb = arg2;
}
else if (typeof arg1 === 'function') {
cb = arg1;
else {
options = arg2;
}
if (title) {
indentation_js_1.indentation.hasDescribe = true;
const { background, icon } = options || {};
/* c8 ignore next */
const message = `${cb ? (0, format_js_1.format)('โ—Œ').dim() : icon || 'โ˜ฐ'} ${cb ? (0, format_js_1.format)(isPoku ? `${title} โ€บ ${(0, format_js_1.format)(`${FILE}`).italic().gray()}` : title).dim() : (0, format_js_1.format)(title).bold() || ''}`;
const noBackground = !background;
if (noBackground) {
write_js_1.Write.log((0, format_js_1.format)(message).bold());
}
else {
write_js_1.Write.log((0, format_js_1.format)(` ${message} `).bg(typeof background === 'string' ? background : 'grey'));
}
}
else if (typeof arg1 === 'function') {
cb = arg1;
options = arg2;
}
if (title) {
indentation_js_1.indentation.hasDescribe = true;
const { background, icon } = options || {};
/* c8 ignore next */
const message = `${cb ? (0, format_js_1.format)('โ—Œ').dim() : icon || 'โ˜ฐ'} ${cb ? (0, format_js_1.format)(isPoku ? `${title} โ€บ ${(0, format_js_1.format)(`${FILE}`).italic().gray()}` : title).dim() : (0, format_js_1.format)(title).bold() || ''}`;
const noBackground = !background;
if (noBackground) {
write_js_1.Write.log((0, format_js_1.format)(message).bold());
}
if (typeof cb !== 'function') {
return;
else {
write_js_1.Write.log((0, format_js_1.format)(` ${message} `).bg(typeof background === 'string' ? background : 'grey'));
}
const start = (0, node_process_1.hrtime)();
const resultCb = cb();
if (resultCb instanceof Promise) {
yield resultCb;
}
const end = (0, node_process_1.hrtime)(start);
if (title) {
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
indentation_js_1.indentation.hasDescribe = false;
write_js_1.Write.log(`${(0, format_js_1.format)(`โ— ${title}`).success().bold()} ${(0, format_js_1.format)(`โ€บ ${total}ms`).success().dim()}`);
}
});
}
if (typeof cb !== 'function') {
return;
}
const start = (0, node_process_1.hrtime)();
const resultCb = cb();
if (resultCb instanceof Promise) {
await resultCb;
}
const end = (0, node_process_1.hrtime)(start);
if (title) {
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
indentation_js_1.indentation.hasDescribe = false;
write_js_1.Write.log(`${(0, format_js_1.format)(`โ— ${title}`).success().bold()} ${(0, format_js_1.format)(`โ€บ ${total}ms`).success().dim()}`);
}
}

@@ -37,2 +37,2 @@ import type { Control, EachOptions } from '../../@types/each.js';

*/
export declare const afterEach: (callback: () => unknown, options?: Omit<EachOptions, "immediate">) => Control;
export declare const afterEach: (callback: () => unknown) => Control;

@@ -23,5 +23,2 @@ "use strict";

const beforeEach = (callback, options) => {
each_js_1.each.before.test = typeof (options === null || options === void 0 ? void 0 : options.test) === 'boolean' ? options.test : true;
each_js_1.each.before.assert =
typeof (options === null || options === void 0 ? void 0 : options.assert) === 'boolean' ? options.assert : false;
(options === null || options === void 0 ? void 0 : options.immediate) && callback();

@@ -63,6 +60,3 @@ each_js_1.each.before.cb = () => {

/* c8 ignore next */ // ?
const afterEach = (callback, options) => {
each_js_1.each.after.test = typeof (options === null || options === void 0 ? void 0 : options.test) === 'boolean' ? options.test : true;
each_js_1.each.after.assert =
typeof (options === null || options === void 0 ? void 0 : options.assert) === 'boolean' ? options.assert : false;
const afterEach = (callback) => {
each_js_1.each.after.cb = () => {

@@ -69,0 +63,0 @@ if (each_js_1.each.after.status) {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -21,6 +12,6 @@ exports.envFile = void 0;

/** Reads an environment file and sets the environment variables. */
const envFile = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (filePath = '.env') {
const envFile = async (filePath = '.env') => {
/* c8 ignore stop */
const mapEnv = new Map();
const env = yield (0, fs_js_1.readFile)((0, list_files_js_1.sanitizePath)(filePath), 'utf8');
const env = await (0, fs_js_1.readFile)((0, list_files_js_1.sanitizePath)(filePath), 'utf8');
const lines = env

@@ -40,3 +31,3 @@ .split('\n')

}
});
};
exports.envFile = envFile;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -15,16 +6,16 @@ exports.getPIDs = void 0;

const pid_js_1 = require("../../services/pid.js");
const getPIDsByPorts = (port) => __awaiter(void 0, void 0, void 0, function* () {
const getPIDsByPorts = async (port) => {
const ports = (0, pid_js_1.setPortsAndPIDs)(port);
const PIDs = [];
yield Promise.all(ports.map((p) => __awaiter(void 0, void 0, void 0, function* () {
PIDs.push(...(yield (get_runner_js_1.isWindows
await Promise.all(ports.map(async (p) => {
PIDs.push(...(await (get_runner_js_1.isWindows
? pid_js_1.getPIDs.windows(p)
: pid_js_1.getPIDs.unix(p))));
})));
}));
return PIDs;
});
const getPIDsByRange = (startsAt, endsAt) => __awaiter(void 0, void 0, void 0, function* () {
};
const getPIDsByRange = async (startsAt, endsAt) => {
const ports = (0, pid_js_1.populateRange)(startsAt, endsAt);
return yield (0, exports.getPIDs)(ports);
});
return await (0, exports.getPIDs)(ports);
};
/** Returns an array containing the ID of all processes listening to the specified port */

@@ -31,0 +22,0 @@ exports.getPIDs = Object.assign(getPIDsByPorts, {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,50 +11,48 @@ exports.it = it;

/* c8 ignore next */ // ?
function it(...args) {
return __awaiter(this, void 0, void 0, function* () {
let message;
let cb;
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
if (typeof each_js_1.each.before.cb === 'function' && each_js_1.each.before.test) {
const beforeResult = each_js_1.each.before.cb();
/* c8 ignore next 3 */
if (beforeResult instanceof Promise) {
yield beforeResult;
}
async function it(...args) {
let message;
let cb;
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
if (typeof each_js_1.each.before.cb === 'function') {
const beforeResult = each_js_1.each.before.cb();
/* c8 ignore next 3 */
if (beforeResult instanceof Promise) {
await beforeResult;
}
if (typeof args[0] === 'string') {
message = args[0];
cb = args[1];
}
else {
cb = args[0];
}
/* c8 ignore start */
if (message) {
indentation_js_1.indentation.hasIt = true;
write_js_1.Write.log(isPoku && !indentation_js_1.indentation.hasDescribe
? `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`โ—Œ ${message} โ€บ ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()}`
: `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`โ—Œ ${message}`).dim()}`);
}
/* c8 ignore stop */
const start = (0, node_process_1.hrtime)();
const resultCb = cb();
}
if (typeof args[0] === 'string') {
message = args[0];
cb = args[1];
}
else {
cb = args[0];
}
/* c8 ignore start */
if (message) {
indentation_js_1.indentation.hasIt = true;
write_js_1.Write.log(isPoku && !indentation_js_1.indentation.hasDescribe
? `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`โ—Œ ${message} โ€บ ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()}`
: `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`โ—Œ ${message}`).dim()}`);
}
/* c8 ignore stop */
const start = (0, node_process_1.hrtime)();
const resultCb = cb();
/* c8 ignore next 3 */
if (resultCb instanceof Promise) {
await resultCb;
}
const end = (0, node_process_1.hrtime)(start);
if (typeof each_js_1.each.after.cb === 'function') {
const afterResult = each_js_1.each.after.cb();
/* c8 ignore next 3 */
if (resultCb instanceof Promise) {
yield resultCb;
if (afterResult instanceof Promise) {
await afterResult;
}
const end = (0, node_process_1.hrtime)(start);
if (typeof each_js_1.each.after.cb === 'function' && each_js_1.each.after.test) {
const afterResult = each_js_1.each.after.cb();
/* c8 ignore next 3 */
if (afterResult instanceof Promise) {
yield afterResult;
}
}
if (message) {
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
indentation_js_1.indentation.hasIt = false;
write_js_1.Write.log(`${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`โ— ${message}`).success().bold()} ${(0, format_js_1.format)(`โ€บ ${total}ms`).success().dim()}`);
}
});
}
if (message) {
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
indentation_js_1.indentation.hasIt = false;
write_js_1.Write.log(`${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`โ— ${message}`).success().bold()} ${(0, format_js_1.format)(`โ€บ ${total}ms`).success().dim()}`);
}
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -16,12 +7,12 @@ exports.kill = void 0;

const get_pids_js_1 = require("./get-pids.js");
const killPID = (PID) => __awaiter(void 0, void 0, void 0, function* () {
const killPID = async (PID) => {
const PIDs = (0, pid_js_1.setPortsAndPIDs)(PID);
yield Promise.all(PIDs.map((p) => __awaiter(void 0, void 0, void 0, function* () {
await Promise.all(PIDs.map(async (p) => {
get_runner_js_1.isWindows
? yield pid_js_1.killPID.windows(p)
: yield pid_js_1.killPID.unix(p);
})));
});
const killPort = (port) => __awaiter(void 0, void 0, void 0, function* () {
const PIDs = yield (0, get_pids_js_1.getPIDs)(port);
? await pid_js_1.killPID.windows(p)
: await pid_js_1.killPID.unix(p);
}));
};
const killPort = async (port) => {
const PIDs = await (0, get_pids_js_1.getPIDs)(port);
for (const PID of PIDs) {

@@ -31,7 +22,7 @@ if (!PID) {

}
yield killPID(PID);
await killPID(PID);
}
});
const killRange = (startsAt, endsAt) => __awaiter(void 0, void 0, void 0, function* () {
const PIDs = yield get_pids_js_1.getPIDs.range(startsAt, endsAt);
};
const killRange = async (startsAt, endsAt) => {
const PIDs = await get_pids_js_1.getPIDs.range(startsAt, endsAt);
for (const PID of PIDs) {

@@ -41,5 +32,5 @@ if (!PID) {

}
yield killPID(PID);
await killPID(PID);
}
});
};
/** Kill processes by PIDs, ports and port ranges. */

@@ -46,0 +37,0 @@ exports.kill = {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var _a;

@@ -35,3 +26,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

exports.sanitizePath = sanitizePath;
const isFile = (fullPath) => __awaiter(void 0, void 0, void 0, function* () { return (yield (0, fs_js_1.stat)(fullPath)).isFile(); });
const isFile = async (fullPath) => (await (0, fs_js_1.stat)(fullPath)).isFile();
exports.isFile = isFile;

@@ -43,4 +34,4 @@ const escapeRegExp = (string) => string.replace(regex.safeRegExp, '\\$&');

: undefined;
const getAllFiles = (dirPath_1, ...args_1) => __awaiter(void 0, [dirPath_1, ...args_1], void 0, function* (dirPath, files = new Set(), configs) {
const currentFiles = yield (0, fs_js_1.readdir)((0, exports.sanitizePath)(dirPath));
const getAllFiles = async (dirPath, files = new Set(), configs) => {
const currentFiles = await (0, fs_js_1.readdir)((0, exports.sanitizePath)(dirPath));
const filter = envFilter

@@ -56,5 +47,5 @@ ? envFilter

: undefined;
yield Promise.all(currentFiles.map((file) => __awaiter(void 0, void 0, void 0, function* () {
await Promise.all(currentFiles.map(async (file) => {
const fullPath = (0, node_path_1.join)(dirPath, file);
const stat = yield (0, fs_js_1.stat)(fullPath);
const stat = await (0, fs_js_1.stat)(fullPath);
/* c8 ignore next 6 */

@@ -76,10 +67,10 @@ if (fullPath.indexOf('node_modules') !== -1 ||

if (stat.isDirectory()) {
yield (0, exports.getAllFiles)(fullPath, files, configs);
await (0, exports.getAllFiles)(fullPath, files, configs);
}
})));
}));
return files;
});
};
exports.getAllFiles = getAllFiles;
/* c8 ignore next */ // ?
const listFiles = (targetDir, configs) => __awaiter(void 0, void 0, void 0, function* () { return Array.from(yield (0, exports.getAllFiles)((0, exports.sanitizePath)(targetDir), new Set(), configs)); });
const listFiles = async (targetDir, configs) => Array.from(await (0, exports.getAllFiles)((0, exports.sanitizePath)(targetDir), new Set(), configs));
exports.listFiles = listFiles;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,50 +11,48 @@ exports.test = test;

/* c8 ignore next */ // ?
function test(...args) {
return __awaiter(this, void 0, void 0, function* () {
let message;
let cb;
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
if (typeof each_js_1.each.before.cb === 'function' && each_js_1.each.before.test) {
const beforeResult = each_js_1.each.before.cb();
/* c8 ignore next 3 */
if (beforeResult instanceof Promise) {
yield beforeResult;
}
async function test(...args) {
let message;
let cb;
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
if (typeof each_js_1.each.before.cb === 'function') {
const beforeResult = each_js_1.each.before.cb();
/* c8 ignore next 3 */
if (beforeResult instanceof Promise) {
await beforeResult;
}
if (typeof args[0] === 'string') {
message = args[0];
cb = args[1];
}
else {
cb = args[0];
}
/* c8 ignore start */
if (message) {
indentation_js_1.indentation.hasTest = true;
write_js_1.Write.log(isPoku
? (0, format_js_1.format)(`โ—Œ ${message} โ€บ ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()
: (0, format_js_1.format)(`โ—Œ ${message}`).dim());
}
/* c8 ignore stop */
const start = (0, node_process_1.hrtime)();
const resultCb = cb();
}
if (typeof args[0] === 'string') {
message = args[0];
cb = args[1];
}
else {
cb = args[0];
}
/* c8 ignore start */
if (message) {
indentation_js_1.indentation.hasTest = true;
write_js_1.Write.log(isPoku
? (0, format_js_1.format)(`โ—Œ ${message} โ€บ ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()
: (0, format_js_1.format)(`โ—Œ ${message}`).dim());
}
/* c8 ignore stop */
const start = (0, node_process_1.hrtime)();
const resultCb = cb();
/* c8 ignore next 3 */
if (resultCb instanceof Promise) {
await resultCb;
}
const end = (0, node_process_1.hrtime)(start);
if (typeof each_js_1.each.after.cb === 'function') {
const afterResult = each_js_1.each.after.cb();
/* c8 ignore next 3 */
if (resultCb instanceof Promise) {
yield resultCb;
if (afterResult instanceof Promise) {
await afterResult;
}
const end = (0, node_process_1.hrtime)(start);
if (typeof each_js_1.each.after.cb === 'function' && each_js_1.each.after.test) {
const afterResult = each_js_1.each.after.cb();
/* c8 ignore next 3 */
if (afterResult instanceof Promise) {
yield afterResult;
}
}
if (message) {
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
indentation_js_1.indentation.hasTest = false;
write_js_1.Write.log(`${(0, format_js_1.format)(`โ— ${message}`).success().bold()} ${(0, format_js_1.format)(`โ€บ ${total}ms`).success().dim()}`);
}
});
}
if (message) {
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
indentation_js_1.indentation.hasTest = false;
write_js_1.Write.log(`${(0, format_js_1.format)(`โ— ${message}`).success().bold()} ${(0, format_js_1.format)(`โ€บ ${total}ms`).success().dim()}`);
}
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -35,3 +26,3 @@ exports.waitForPort = exports.waitForExpectedResult = exports.sleep = void 0;

/** Wait until a result is equal the expected value. */
const waitForExpectedResult = (callback, expectedResult, options) => __awaiter(void 0, void 0, void 0, function* () {
const waitForExpectedResult = async (callback, expectedResult, options) => {
const delay = (options === null || options === void 0 ? void 0 : options.delay) || 0;

@@ -54,6 +45,6 @@ const interval = (options === null || options === void 0 ? void 0 : options.interval) || 100;

/* c8 ignore stop */
yield (0, exports.sleep)(delay);
await (0, exports.sleep)(delay);
const startTime = Date.now();
while (true) {
const result = yield callback();
const result = await callback();
if (typeof expectedResult === 'function') {

@@ -82,10 +73,10 @@ if (typeof result === 'function' && result.name === expectedResult.name) {

}
yield (0, exports.sleep)(interval);
await (0, exports.sleep)(interval);
}
yield (0, exports.sleep)(delay);
});
await (0, exports.sleep)(delay);
};
exports.waitForExpectedResult = waitForExpectedResult;
/* c8 ignore next 2 */ // ?
/** Wait until the defined port is active. */
const waitForPort = (port, options) => __awaiter(void 0, void 0, void 0, function* () {
const waitForPort = async (port, options) => {
const host = (options === null || options === void 0 ? void 0 : options.host) || 'localhost';

@@ -95,4 +86,4 @@ if (!Number.isInteger(port)) {

}
yield (0, exports.waitForExpectedResult)(() => __awaiter(void 0, void 0, void 0, function* () { return yield checkPort(port, host); }), true, options);
});
await (0, exports.waitForExpectedResult)(async () => await checkPort(port, host), true, options);
};
exports.waitForPort = waitForPort;
export { poku } from './essentials/poku.js';
export { assert } from './essentials/assert.js';
export { strict } from './essentials/strict.js';
export { test } from './helpers/test.js';

@@ -16,4 +17,3 @@ export { describe } from './helpers/describe.js';

export { log } from './helpers/log.js';
export { publicListFiles as listFiles } from './helpers/list-files-sync.js';
export { assertPromise } from './helpers/assert-promise.js';
export { listFiles } from './helpers/list-files.js';
export type { Code } from '../@types/code.js';

@@ -20,0 +20,0 @@ export type { Configs } from '../@types/poku.js';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertPromise = exports.listFiles = exports.log = exports.exit = exports.getPIDs = exports.kill = exports.sleep = exports.waitForPort = exports.waitForExpectedResult = exports.startService = exports.startScript = exports.docker = exports.afterEach = exports.beforeEach = exports.skip = exports.envFile = exports.it = exports.describe = exports.test = exports.assert = exports.poku = void 0;
exports.listFiles = exports.log = exports.exit = exports.getPIDs = exports.kill = exports.sleep = exports.waitForPort = exports.waitForExpectedResult = exports.startService = exports.startScript = exports.docker = exports.afterEach = exports.beforeEach = exports.skip = exports.envFile = exports.it = exports.describe = exports.test = exports.strict = exports.assert = exports.poku = void 0;
var poku_js_1 = require("./essentials/poku.js");

@@ -8,2 +8,4 @@ Object.defineProperty(exports, "poku", { enumerable: true, get: function () { return poku_js_1.poku; } });

Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_js_1.assert; } });
var strict_js_1 = require("./essentials/strict.js");
Object.defineProperty(exports, "strict", { enumerable: true, get: function () { return strict_js_1.strict; } });
var test_js_1 = require("./helpers/test.js");

@@ -39,5 +41,3 @@ Object.defineProperty(exports, "test", { enumerable: true, get: function () { return test_js_1.test; } });

Object.defineProperty(exports, "log", { enumerable: true, get: function () { return log_js_1.log; } });
var list_files_sync_js_1 = require("./helpers/list-files-sync.js");
Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return list_files_sync_js_1.publicListFiles; } });
var assert_promise_js_1 = require("./helpers/assert-promise.js");
Object.defineProperty(exports, "assertPromise", { enumerable: true, get: function () { return assert_promise_js_1.assertPromise; } });
var list_files_js_1 = require("./helpers/list-files.js");
Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return list_files_js_1.listFiles; } });

@@ -5,7 +5,6 @@ "use strict";

/* c8 ignore next */ // ?
const pad_js_1 = require("../polyfills/pad.js");
const parseTime = (date) => {
const hours = (0, pad_js_1.padStart)(date.getHours().toString(), 2, '0');
const minutes = (0, pad_js_1.padStart)(date.getMinutes().toString(), 2, '0');
const seconds = (0, pad_js_1.padStart)(date.getSeconds().toString(), 2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const seconds = date.getSeconds().toString().padStart(2, '0');
return `${hours}:${minutes}:${seconds}`;

@@ -12,0 +11,0 @@ };

@@ -1,7 +0,4 @@

import { type Dirent, type Stats } from 'node:fs';
export declare function readdir(path: string): Promise<string[]>;
export declare function readdir(path: string, options: {
withFileTypes: true;
}): Promise<Dirent[]>;
export declare const stat: (path: string) => Promise<Stats>;
export declare const readFile: (path: string, encoding?: BufferEncoding) => Promise<string>;
import { stat as nodeStat, readdir as nodeReaddir, readFile as nodeReadFile } from 'node:fs';
export declare const readdir: typeof nodeReaddir.__promisify__;
export declare const stat: typeof nodeStat.__promisify__;
export declare const readFile: typeof nodeReadFile.__promisify__;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readFile = exports.stat = void 0;
exports.readdir = readdir;
exports.readFile = exports.stat = exports.readdir = void 0;
const node_fs_1 = require("fs");
function readdir(path, options) {
return new Promise((resolve, reject) => {
if (options === null || options === void 0 ? void 0 : options.withFileTypes) {
(0, node_fs_1.readdir)(path, { withFileTypes: true }, (err, entries) => {
if (err) {
return reject(err);
}
resolve(entries);
});
return;
}
(0, node_fs_1.readdir)(path, (err, files) => {
if (err) {
return reject(err);
}
resolve(files);
});
});
}
const stat = (path) => {
return new Promise((resolve, reject) => {
(0, node_fs_1.stat)(path, (err, stats) => {
if (err) {
return reject(err);
}
resolve(stats);
});
});
};
exports.stat = stat;
const readFile = (path, encoding = 'utf-8') => new Promise((resolve, reject) => {
(0, node_fs_1.readFile)(path, encoding, (err, data) => {
if (err) {
return reject(err);
}
resolve(data);
});
});
exports.readFile = readFile;
const node_util_1 = require("util");
exports.readdir = (0, node_util_1.promisify)(node_fs_1.readdir);
exports.stat = (0, node_util_1.promisify)(node_fs_1.stat);
exports.readFile = (0, node_util_1.promisify)(node_fs_1.readFile);
import type { ProcessAssertionOptions } from '../@types/assert.js';
import type assert from 'node:assert';
import type { AssertPredicate } from 'node:assert';
export declare const processAssert: (cb: () => void | Promise<void>, options: ProcessAssertionOptions) => Promise<void>;
export declare const createAssert: (nodeAssert: typeof assert) => ((value: unknown, message?: ProcessAssertionOptions["message"]) => void) & {
ok: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
equal: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
deepEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
strictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
deepStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
doesNotMatch: (value: string, regExp: RegExp, message?: ProcessAssertionOptions["message"]) => void;
doesNotReject: {
(block: (() => Promise<unknown>) | Promise<unknown>, message?: ProcessAssertionOptions["message"]): Promise<void>;
(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: ProcessAssertionOptions["message"]): Promise<void>;
};
throws: {
(block: () => unknown, message?: ProcessAssertionOptions["message"]): void;
(block: () => unknown, error: AssertPredicate, message?: ProcessAssertionOptions["message"]): void;
};
doesNotThrow: {
(block: () => unknown, message?: string | ProcessAssertionOptions["message"]): void;
(block: () => unknown, error: AssertPredicate, message?: ProcessAssertionOptions["message"]): void;
};
notEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notDeepEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notDeepStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
match: (value: string, regExp: RegExp, message?: ProcessAssertionOptions["message"]) => void;
ifError: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
fail: (message?: ProcessAssertionOptions["message"]) => never;
rejects: {
(block: (() => Promise<unknown>) | Promise<unknown>, message?: ProcessAssertionOptions["message"]): Promise<void>;
(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: ProcessAssertionOptions["message"]): Promise<void>;
};
};
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -15,9 +6,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.processAssert = void 0;
exports.createAssert = exports.processAssert = void 0;
const node_assert_1 = require("assert");
const node_process_1 = require("process");
const node_path_1 = __importDefault(require("path"));
const node_assert_1 = require("assert");
const find_file_from_stack_js_1 = require("../parsers/find-file-from-stack.js");
const assert_js_1 = require("../parsers/assert.js");
const each_js_1 = require("../configs/each.js");
const get_runtime_js_1 = require("../parsers/get-runtime.js");
const indentation_js_1 = require("../configs/indentation.js");

@@ -28,3 +19,3 @@ const format_js_1 = require("./format.js");

const regexFile = /file:(\/\/)?/;
const processAssert = (cb, options) => __awaiter(void 0, void 0, void 0, function* () {
const processAssert = async (cb, options) => {
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;

@@ -40,21 +31,7 @@ const FILE = node_process_1.env.FILE;

try {
if (typeof each_js_1.each.before.cb === 'function' && each_js_1.each.before.assert) {
const beforeResult = each_js_1.each.before.cb();
/* c8 ignore next 3 */
if (beforeResult instanceof Promise) {
yield beforeResult;
}
}
const cbResult = cb();
/* c8 ignore next 3 */
if (cbResult instanceof Promise) {
yield cbResult;
await cbResult;
}
if (typeof each_js_1.each.after.cb === 'function' && each_js_1.each.after.assert) {
const afterResult = each_js_1.each.after.cb();
/* c8 ignore next 3 */
if (afterResult instanceof Promise) {
yield afterResult;
}
}
if (typeof options.message === 'string') {

@@ -119,3 +96,183 @@ const message = isPoku &&

/* c8 ignore stop */
});
};
exports.processAssert = processAssert;
/* c8 ignore next */ // ?
const createAssert = (nodeAssert) => {
const ok = (value, message) => {
(0, exports.processAssert)(() => {
nodeAssert.ok(value);
}, { message });
};
const equal = (actual, expected, message) => {
(0, exports.processAssert)(() => {
nodeAssert.equal(actual, expected);
}, { message });
};
const deepEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.deepEqual(actual, expected), { message });
};
const strictEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.strictEqual(actual, expected), { message });
};
const deepStrictEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.deepStrictEqual(actual, expected), {
message,
});
};
const notEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.notEqual(actual, expected), {
message,
});
};
const notDeepEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.notDeepEqual(actual, expected), { message });
};
const notStrictEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.notStrictEqual(actual, expected), {
message,
});
};
const notDeepStrictEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.notDeepStrictEqual(actual, expected), {
message,
});
};
const ifError = (value, message) => {
(0, exports.processAssert)(() => {
nodeAssert.ifError(value);
}, {
message,
defaultMessage: 'Expected no error, but received an error',
hideDiff: true,
throw: true,
});
};
/* c8 ignore start */
const fail = (message) => {
(0, exports.processAssert)(() => {
nodeAssert.fail(message);
}, {
message,
defaultMessage: 'Test failed intentionally',
hideDiff: true,
});
process.exit(1);
};
function doesNotThrow(block, errorOrMessage, message) {
(0, exports.processAssert)(() => {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
nodeAssert.doesNotThrow(block, errorOrMessage, message);
}
else {
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
nodeAssert.doesNotThrow(block, msg);
}
}, {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Expected function not to throw',
hideDiff: true,
throw: true,
});
}
function throws(block, errorOrMessage, message) {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
(0, exports.processAssert)(() => nodeAssert.throws(block, errorOrMessage), {
message,
defaultMessage: 'Expected function to throw',
hideDiff: true,
});
}
else {
const msg = typeof errorOrMessage !== 'undefined' ? errorOrMessage : message;
(0, exports.processAssert)(() => nodeAssert.throws(block, message), {
message: msg,
defaultMessage: 'Expected function to throw',
hideDiff: true,
});
}
}
async function rejects(block, errorOrMessage, message) {
await (0, exports.processAssert)(async () => {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
await nodeAssert.rejects(block, errorOrMessage, message);
}
else {
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
await nodeAssert.rejects(block, msg);
}
}, {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Expected promise to be rejected with specified error',
hideDiff: true,
throw: true,
});
}
async function doesNotReject(block, errorOrMessage, message) {
await (0, exports.processAssert)(async () => {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
await nodeAssert.doesNotReject(block, errorOrMessage, message);
}
else {
await nodeAssert.doesNotReject(block, message);
}
}, {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Got unwanted rejection',
hideDiff: true,
throw: true,
});
}
const match = (value, regExp, message) => {
/* c8 ignore next 3 */
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12) {
throw new Error('match is available from Node.js 12 or higher');
}
(0, exports.processAssert)(() => nodeAssert === null || nodeAssert === void 0 ? void 0 : nodeAssert.match(value, regExp), {
message,
actual: 'Value',
expected: 'RegExp',
defaultMessage: 'Value should match regExp',
});
};
const doesNotMatch = (value, regExp, message) => {
/* c8 ignore next 3 */
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12) {
throw new Error('doesNotMatch is available from Node.js 12 or higher');
}
(0, exports.processAssert)(() => nodeAssert.doesNotMatch(value, regExp), {
message,
actual: 'Value',
expected: 'RegExp',
defaultMessage: 'Value should not match regExp',
});
};
const assert = Object.assign((value, message) => ok(value, message), {
ok,
equal,
deepEqual,
strictEqual,
deepStrictEqual,
doesNotMatch,
doesNotReject,
throws,
doesNotThrow,
notEqual,
notDeepEqual,
notStrictEqual,
notDeepStrictEqual,
match,
ifError,
fail,
rejects,
});
return assert;
};
exports.createAssert = createAssert;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,3 +10,6 @@ exports.DockerCompose = exports.DockerContainer = void 0;

return new Promise((resolve) => {
const dockerProcess = (0, node_child_process_1.spawn)(command, args, Object.assign(Object.assign({}, options), { shell: get_runner_js_1.isWindows }));
const dockerProcess = (0, node_child_process_1.spawn)(command, args, {
...options,
shell: get_runner_js_1.isWindows,
});
if (verbose) {

@@ -48,38 +42,30 @@ dockerProcess.stdout.on('data', write_js_1.Write.log);

}
build() {
return __awaiter(this, void 0, void 0, function* () {
const args = ['build'];
if (this.cache === false) {
args.push('--no-cache');
}
yield runDockerCommand('docker', [...args, '-t', this.tagName, '-f', this.file, this.context], { cwd: this.cwd }, this.verbose);
});
async build() {
const args = ['build'];
if (this.cache === false) {
args.push('--no-cache');
}
await runDockerCommand('docker', [...args, '-t', this.tagName, '-f', this.file, this.context], { cwd: this.cwd }, this.verbose);
}
start() {
return __awaiter(this, void 0, void 0, function* () {
const args = ['run'];
args.push(this.detach !== false ? '-d' : '--init');
args.push(...['--name', this.containerName]);
for (const port of this.ports) {
args.push(...['-p', port]);
}
for (const environment of this.environments) {
args.push(...['-e', environment]);
}
if (this.envFile) {
args.push(...['--env-file', this.envFile]);
}
return yield runDockerCommand('docker', [...args, this.tagName], { cwd: this.cwd }, this.verbose);
});
async start() {
const args = ['run'];
args.push(this.detach !== false ? '-d' : '--init');
args.push(...['--name', this.containerName]);
for (const port of this.ports) {
args.push(...['-p', port]);
}
for (const environment of this.environments) {
args.push(...['-e', environment]);
}
if (this.envFile) {
args.push(...['--env-file', this.envFile]);
}
return await runDockerCommand('docker', [...args, this.tagName], { cwd: this.cwd }, this.verbose);
}
stop() {
return __awaiter(this, void 0, void 0, function* () {
return yield runDockerCommand('docker', ['stop', this.containerName], { cwd: this.cwd }, this.verbose);
});
async stop() {
return await runDockerCommand('docker', ['stop', this.containerName], { cwd: this.cwd }, this.verbose);
}
remove() {
return __awaiter(this, void 0, void 0, function* () {
yield runDockerCommand('docker', ['rm', '-f', this.containerName], { cwd: this.cwd }, this.verbose);
yield runDockerCommand('docker', ['image', 'rm', '-f', this.tagName], { cwd: this.cwd }, this.verbose);
});
async remove() {
await runDockerCommand('docker', ['rm', '-f', this.containerName], { cwd: this.cwd }, this.verbose);
await runDockerCommand('docker', ['image', 'rm', '-f', this.tagName], { cwd: this.cwd }, this.verbose);
}

@@ -100,35 +86,31 @@ }

}
up() {
return __awaiter(this, void 0, void 0, function* () {
const args = ['-f', this.file];
if (this.envFile) {
args.push(...['--env-file', this.envFile]);
}
if (this.projectName) {
args.push(...['-p', this.projectName]);
}
args.push('up');
args.push(this.detach !== false ? '-d' : '--abort-on-container-exit');
if (this.build) {
args.push('--build');
}
if (this.serviceName) {
args.push(this.serviceName);
}
return yield runDockerCommand('docker-compose', args, { cwd: this.cwd }, this.verbose);
});
async up() {
const args = ['-f', this.file];
if (this.envFile) {
args.push(...['--env-file', this.envFile]);
}
if (this.projectName) {
args.push(...['-p', this.projectName]);
}
args.push('up');
args.push(this.detach !== false ? '-d' : '--abort-on-container-exit');
if (this.build) {
args.push('--build');
}
if (this.serviceName) {
args.push(this.serviceName);
}
return await runDockerCommand('docker-compose', args, { cwd: this.cwd }, this.verbose);
}
down() {
return __awaiter(this, void 0, void 0, function* () {
const args = ['-f', this.file];
if (this.envFile) {
args.push(...['--env-file', this.envFile]);
}
if (this.projectName) {
args.push(...['-p', this.projectName]);
}
return yield runDockerCommand('docker-compose', [...args, 'down'], { cwd: this.cwd }, this.verbose);
});
async down() {
const args = ['-f', this.file];
if (this.envFile) {
args.push(...['--env-file', this.envFile]);
}
if (this.projectName) {
args.push(...['-p', this.projectName]);
}
return await runDockerCommand('docker-compose', [...args, 'down'], { cwd: this.cwd }, this.verbose);
}
}
exports.DockerCompose = DockerCompose;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -16,3 +7,3 @@ exports.afterEach = exports.beforeEach = void 0;

const output_js_1 = require("../parsers/output.js");
const eachCore = (type, fileRelative, configs) => __awaiter(void 0, void 0, void 0, function* () {
const eachCore = async (type, fileRelative, configs) => {
/* c8 ignore next 3 */

@@ -30,3 +21,3 @@ if (typeof (configs === null || configs === void 0 ? void 0 : configs[type]) !== 'function') {

try {
yield cb();
await cb();
return true;

@@ -48,17 +39,17 @@ }

}
});
const beforeEach = (fileRelative, configs) => __awaiter(void 0, void 0, void 0, function* () {
};
const beforeEach = async (fileRelative, configs) => {
if (configs === null || configs === void 0 ? void 0 : configs.beforeEach) {
return yield eachCore('beforeEach', fileRelative, configs);
return await eachCore('beforeEach', fileRelative, configs);
}
return true;
});
};
exports.beforeEach = beforeEach;
/* c8 ignore next */ // ?
const afterEach = (fileRelative, configs) => __awaiter(void 0, void 0, void 0, function* () {
const afterEach = async (fileRelative, configs) => {
if (configs === null || configs === void 0 ? void 0 : configs.afterEach) {
return yield eachCore('afterEach', fileRelative, configs);
return await eachCore('afterEach', fileRelative, configs);
}
return true;
});
};
exports.afterEach = afterEach;

@@ -5,3 +5,2 @@ "use strict";

/* c8 ignore next */ // ?
const pad_js_1 = require("../polyfills/pad.js");
exports.backgroundColor = {

@@ -34,3 +33,3 @@ white: 7,

const totalDigits = String(total).length;
const formattedCounter = (0, pad_js_1.padStart)(String(current), totalDigits, pad);
const formattedCounter = String(current).padStart(totalDigits, pad);
this.parts += formattedCounter;

@@ -37,0 +36,0 @@ return this;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -61,5 +52,5 @@ exports.mapTests = exports.findMatchingFiles = exports.getDeepImports = exports.normalizePath = void 0;

exports.findMatchingFiles = findMatchingFiles;
const collectTestFiles = (testPaths, testFilter, exclude) => __awaiter(void 0, void 0, void 0, function* () {
const collectTestFiles = async (testPaths, testFilter, exclude) => {
const statsPromises = testPaths.map((testPath) => (0, fs_js_1.stat)(testPath));
const stats = yield Promise.all(statsPromises);
const stats = await Promise.all(statsPromises);
const listFilesPromises = stats.map((stat, index) => {

@@ -79,7 +70,7 @@ const testPath = testPaths[index];

});
const nestedTestFiles = yield Promise.all(listFilesPromises);
const nestedTestFiles = await Promise.all(listFilesPromises);
return new Set(nestedTestFiles.flat());
});
};
/* c8 ignore start */
const processDeepImports = (srcFile, testFile, intersectedSrcFiles) => __awaiter(void 0, void 0, void 0, function* () {
const processDeepImports = async (srcFile, testFile, intersectedSrcFiles) => {
if (processedFiles.has(srcFile)) {

@@ -89,3 +80,3 @@ return;

processedFiles.add(srcFile);
const srcContent = yield (0, fs_js_1.readFile)(srcFile, 'utf-8');
const srcContent = await (0, fs_js_1.readFile)(srcFile, 'utf-8');
const deepImports = (0, exports.getDeepImports)(srcContent);

@@ -98,12 +89,12 @@ const matchingFiles = (0, exports.findMatchingFiles)(deepImports, intersectedSrcFiles);

importMap.get(deepImport).add((0, exports.normalizePath)(testFile));
yield processDeepImports(deepImport, testFile, intersectedSrcFiles);
await processDeepImports(deepImport, testFile, intersectedSrcFiles);
}
});
};
/* c8 ignore stop */
/* c8 ignore start */
const createImportMap = (allTestFiles, allSrcFiles) => __awaiter(void 0, void 0, void 0, function* () {
const createImportMap = async (allTestFiles, allSrcFiles) => {
const intersectedSrcFiles = new Set(Array.from(allSrcFiles).filter((srcFile) => !allTestFiles.has(srcFile)));
yield Promise.all(Array.from(allTestFiles).map((testFile) => __awaiter(void 0, void 0, void 0, function* () {
await Promise.all(Array.from(allTestFiles).map(async (testFile) => {
var _a;
const content = yield (0, fs_js_1.readFile)(testFile, 'utf-8');
const content = await (0, fs_js_1.readFile)(testFile, 'utf-8');
for (const srcFile of intersectedSrcFiles) {

@@ -118,11 +109,11 @@ const relativePath = (0, exports.normalizePath)((0, node_path_1.relative)((0, node_path_1.dirname)(testFile), srcFile));

(_a = importMap.get(normalizedSrcFile)) === null || _a === void 0 ? void 0 : _a.add((0, exports.normalizePath)(testFile));
yield processDeepImports(srcFile, testFile, intersectedSrcFiles);
await processDeepImports(srcFile, testFile, intersectedSrcFiles);
}
}
})));
});
}));
};
/* c8 ignore stop */
/* c8 ignore next */ // ?
const mapTests = (srcDir, testPaths, testFilter, exclude) => __awaiter(void 0, void 0, void 0, function* () {
const [allTestFiles, allSrcFiles] = yield Promise.all([
const mapTests = async (srcDir, testPaths, testFilter, exclude) => {
const [allTestFiles, allSrcFiles] = await Promise.all([
collectTestFiles(testPaths, testFilter, exclude),

@@ -134,5 +125,5 @@ (0, list_files_js_1.listFiles)(srcDir, {

]);
yield createImportMap(allTestFiles, new Set(allSrcFiles));
await createImportMap(allTestFiles, new Set(allSrcFiles));
return importMap;
});
};
exports.mapTests = mapTests;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -25,3 +16,3 @@ exports.runTestFile = void 0;

/* c8 ignore next */ // ?
const runTestFile = (filePath, configs) => __awaiter(void 0, void 0, void 0, function* () {
const runTestFile = async (filePath, configs) => {
var _a, _b;

@@ -53,3 +44,3 @@ /* c8 ignore start */

/* c8 ignore next 3 */
if (!(yield (0, each_js_1.beforeEach)(fileRelative, configs))) {
if (!(await (0, each_js_1.beforeEach)(fileRelative, configs))) {
return false;

@@ -62,7 +53,10 @@ }

shell: get_runner_js_1.isWindows,
env: Object.assign(Object.assign({}, node_process_1.env), { FILE: (configs === null || configs === void 0 ? void 0 : configs.parallel) || ((_a = configs === null || configs === void 0 ? void 0 : configs.deno) === null || _a === void 0 ? void 0 : _a.cjs) ? fileRelative : '' }),
env: {
...node_process_1.env,
FILE: (configs === null || configs === void 0 ? void 0 : configs.parallel) || ((_a = configs === null || configs === void 0 ? void 0 : configs.deno) === null || _a === void 0 ? void 0 : _a.cjs) ? fileRelative : '',
},
});
child.stdout.on('data', stdOut);
child.stderr.on('data', stdOut);
child.on('close', (code) => __awaiter(void 0, void 0, void 0, function* () {
child.on('close', async (code) => {
end = (0, node_process_1.hrtime)(start);

@@ -79,3 +73,3 @@ const result = code === 0;

/* c8 ignore next 4 */
if (!(yield (0, each_js_1.afterEach)(fileRelative, configs))) {
if (!(await (0, each_js_1.afterEach)(fileRelative, configs))) {
resolve(false);

@@ -92,3 +86,3 @@ return;

resolve(result);
}));
});
/* c8 ignore start */

@@ -104,3 +98,3 @@ child.on('error', (err) => {

});
});
};
exports.runTestFile = runTestFile;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -24,9 +15,9 @@ exports.runTestsParallel = exports.runTests = void 0;

const cwd = (0, node_process_1.cwd)();
const runTests = (dir, configs) => __awaiter(void 0, void 0, void 0, function* () {
const runTests = async (dir, configs) => {
const testDir = (0, node_path_1.join)(cwd, dir);
const currentDir = (0, node_path_1.relative)(cwd, testDir);
const isFile = yield (0, list_files_js_1.isFile)(testDir);
const isFile = await (0, list_files_js_1.isFile)(testDir);
const files = isFile
? [(0, list_files_js_1.sanitizePath)(testDir)]
: yield (0, list_files_js_1.listFiles)(testDir, configs);
: await (0, list_files_js_1.listFiles)(testDir, configs);
const totalTests = files.length;

@@ -43,3 +34,3 @@ const showLogs = !(0, output_js_1.isQuiet)(configs);

const start = (0, node_process_1.hrtime)();
const testPassed = yield (0, run_test_file_js_1.runTestFile)(filePath, configs);
const testPassed = await (0, run_test_file_js_1.runTestFile)(filePath, configs);
const end = (0, node_process_1.hrtime)(start);

@@ -75,10 +66,10 @@ const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);

return passed;
});
};
exports.runTests = runTests;
/* c8 ignore next */ // ?
const runTestsParallel = (dir, configs) => __awaiter(void 0, void 0, void 0, function* () {
const runTestsParallel = async (dir, configs) => {
const testDir = (0, node_path_1.join)(cwd, dir);
const files = (yield (0, list_files_js_1.isFile)(dir))
const files = (await (0, list_files_js_1.isFile)(dir))
? [(0, list_files_js_1.sanitizePath)(dir)]
: yield (0, list_files_js_1.listFiles)(testDir, configs);
: await (0, list_files_js_1.listFiles)(testDir, configs);
const filesByConcurrency = [];

@@ -98,3 +89,3 @@ const concurrencyLimit = (configs === null || configs === void 0 ? void 0 : configs.concurrency) || 0;

for (const fileGroup of filesByConcurrency) {
const promises = fileGroup.map((filePath) => __awaiter(void 0, void 0, void 0, function* () {
const promises = fileGroup.map(async (filePath) => {
/* c8 ignore next 3 */

@@ -104,3 +95,3 @@ if ((configs === null || configs === void 0 ? void 0 : configs.failFast) && poku_js_1.results.fail > 0) {

}
const testPassed = yield (0, run_test_file_js_1.runTestFile)(filePath, configs);
const testPassed = await (0, run_test_file_js_1.runTestFile)(filePath, configs);
/* c8 ignore start */

@@ -117,4 +108,4 @@ if (!testPassed) {

return true;
}));
const concurrency = yield Promise.all(promises);
});
const concurrency = await Promise.all(promises);
concurrencyResults.push(concurrency);

@@ -133,3 +124,3 @@ }

/* c8 ignore stop */
});
};
exports.runTestsParallel = runTestsParallel;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -51,53 +42,49 @@ exports.watch = exports.Watcher = void 0;

}
watchDirectory(dir) {
return __awaiter(this, void 0, void 0, function* () {
/* c8 ignore next 3 */
if (this.dirWatchers.has(dir)) {
return;
}
const watcher = (0, node_fs_1.watch)(dir, (_, filename) => __awaiter(this, void 0, void 0, function* () {
if (filename) {
const fullPath = (0, node_path_1.join)(dir, filename);
this.files = yield (0, list_files_js_1.listFiles)(this.rootDir);
this.watchFiles(this.files);
try {
const stats = yield (0, fs_js_1.stat)(fullPath);
if (stats.isDirectory()) {
yield this.watchDirectory(fullPath);
}
/* c8 ignore next */
async watchDirectory(dir) {
/* c8 ignore next 3 */
if (this.dirWatchers.has(dir)) {
return;
}
const watcher = (0, node_fs_1.watch)(dir, async (_, filename) => {
if (filename) {
const fullPath = (0, node_path_1.join)(dir, filename);
this.files = await (0, list_files_js_1.listFiles)(this.rootDir);
this.watchFiles(this.files);
try {
const stats = await (0, fs_js_1.stat)(fullPath);
if (stats.isDirectory()) {
await this.watchDirectory(fullPath);
}
catch (_a) { }
/* c8 ignore next */
}
}));
/* c8 ignore next 3 */
watcher.on('error', () => {
return;
});
this.dirWatchers.set(dir, watcher);
const entries = yield (0, fs_js_1.readdir)(dir, { withFileTypes: true });
for (const entry of entries) {
if (entry.isDirectory()) {
const fullPath = (0, node_path_1.join)(dir, entry.name);
yield this.watchDirectory(fullPath);
}
catch (_a) { }
}
});
/* c8 ignore next 3 */
watcher.on('error', () => {
return;
});
this.dirWatchers.set(dir, watcher);
const entries = await (0, fs_js_1.readdir)(dir, { withFileTypes: true });
for (const entry of entries) {
if (entry.isDirectory()) {
const fullPath = (0, node_path_1.join)(dir, entry.name);
await this.watchDirectory(fullPath);
}
}
}
start() {
return __awaiter(this, void 0, void 0, function* () {
try {
const stats = yield (0, fs_js_1.stat)(this.rootDir);
if (stats.isDirectory()) {
this.files = yield (0, list_files_js_1.listFiles)(this.rootDir);
this.watchFiles(this.files);
yield this.watchDirectory(this.rootDir);
}
else {
this.watchFile(this.rootDir);
}
/* c8 ignore next */
async start() {
try {
const stats = await (0, fs_js_1.stat)(this.rootDir);
if (stats.isDirectory()) {
this.files = await (0, list_files_js_1.listFiles)(this.rootDir);
this.watchFiles(this.files);
await this.watchDirectory(this.rootDir);
}
catch (_a) { }
});
else {
this.watchFile(this.rootDir);
}
/* c8 ignore next */
}
catch (_a) { }
}

@@ -117,7 +104,7 @@ stop() {

/* c8 ignore next */ // ?
const watch = (path, callback) => __awaiter(void 0, void 0, void 0, function* () {
const watch = async (path, callback) => {
const watcher = new Watcher(path, callback);
yield watcher.start();
await watcher.start();
return watcher;
});
};
exports.watch = watch;
{
"name": "poku",
"version": "1.23.0",
"version": "2.0.0",
"description": "๐Ÿท Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",

@@ -24,5 +24,7 @@ "main": "./lib/modules/index.js",

},
"files": ["lib"],
"files": [
"lib"
],
"engines": {
"node": ">=6.0.0",
"node": ">=8.17.0",
"bun": ">=1.0.0",

@@ -49,10 +51,12 @@ "deno": ">=1.30.0",

"docker:deno": "docker compose -f test/docker/playground/deno/docker-compose.yml up --build",
"clear": "shx rm -rf lib ci coverage",
"clear": "rm -rf lib ci coverage",
"prebuild": "npm run clear",
"build": "tsc && tsc -p tsconfig.test.json",
"postbuild": "tsx tools/compatibility/node.ts && shx cp fixtures/server/package.json ci/fixtures/server/package.json && npm run build:deno && shx chmod +x lib/bin/index.js",
"postbuild": "tsx tools/compatibility/node.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && npm run build:deno && chmod +x lib/bin/index.js",
"build:deno": "tsc -p tsconfig.mjs.json",
"postbuild:deno": "tsx tools/build/check-deno-polyfill.ts",
"lint:check": "npx @biomejs/biome lint && npx @biomejs/biome format",
"lint:fix": "npx @biomejs/biome lint --write && npx @biomejs/biome format --write",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .github/workflows/*.yml .",
"lint:check": "npx @biomejs/biome lint && npm run prettier:check",
"lint:fix": "npx @biomejs/biome lint --write && npm run prettier:fix",
"update": "pu minor && npm i && npm audit fix",

@@ -67,3 +71,3 @@ "postupdate": "npm run lint:fix",

"packages-update": "^2.0.0",
"shx": "^0.3.4",
"prettier": "^3.3.2",
"tsx": "4.16.2",

@@ -70,0 +74,0 @@ "typescript": "^5.5.3"

@@ -159,4 +159,8 @@ <div align="center">

<td><a href="https://poku.io/docs/documentation/assert">assert</a></td>
<td>๐Ÿ”ฌ Test assertion <i>(<strong>Node.js</strong> familiar <strong>API</strong>)</i>.</td>
<td>๐Ÿ” Test assertion <i>(<strong>Node.js</strong> familiar <strong>API</strong>)</i>.</td>
</tr>
<tr>
<td><a href="https://poku.io/docs/documentation/assert">strict</a></td>
<td>๐Ÿ”ฌ Strict test assertion <i>(<strong>Node.js</strong> familiar <strong>API</strong>)</i>.</td>
</tr>
</table>

@@ -258,2 +262,3 @@

- [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).
- [Migrating to version **2.x**](https://github.com/wellwelwel/poku/issues/533).

@@ -260,0 +265,0 @@ ---

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc