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

poku

Package Overview
Dependencies
Maintainers
1
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 2.5.0 to 2.5.1-canary.b756605

lib/modules/helpers/it/skip.d.ts

3

lib/@types/poku.d.ts

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

};
export type Runtime = 'node' | 'bun' | 'deno';
export type Configs = {

@@ -40,3 +41,3 @@ /**

*/
platform?: 'node' | 'bun' | 'deno';
platform?: Runtime;
/**

@@ -43,0 +44,0 @@ * Stops the tests at the first failure.

@@ -42,5 +42,4 @@ "use strict";

const flagName = arg.split('=')[0];
if (!allowedFlags.has(flagName) && flagName.startsWith('-')) {
if (!allowedFlags.has(flagName) && flagName.startsWith('-'))
unrecognizedFlags.push(flagName);
}
}

@@ -47,0 +46,0 @@ if (unrecognizedFlags.length > 0) {

@@ -28,5 +28,4 @@ #! /usr/bin/env node

const includeArg = (0, get_arg_js_1.getArg)('include');
if (includeArg !== undefined) {
if (includeArg !== undefined)
return includeArg.split(',');
}
return ((_a = (0, get_arg_js_1.getPaths)('-')) !== null && _a !== void 0 ? _a : ((defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)

@@ -56,11 +55,9 @@ ? Array.prototype.concat(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)

const concurrency = (() => {
if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel))) {
return undefined;
}
if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel)))
return;
const value = Number((0, get_arg_js_1.getArg)('concurrency'));
return Number.isNaN(value) ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.concurrency : value;
})();
if (dirs.length === 1) {
if (dirs.length === 1)
files_js_1.states.isSinglePath = true;
}
if ((0, get_arg_js_1.hasArg)('listfiles')) {

@@ -70,3 +67,3 @@ const { listFiles } = require('../modules/helpers/list-files.js');

write_js_1.Write.hr();
for (const dir of dirs) {
for (const dir of dirs)
files.push(...(await listFiles(dir, {

@@ -80,3 +77,2 @@ filter: typeof filter === 'string'

})));
}
write_js_1.Write.log(files

@@ -83,0 +79,0 @@ .sort()

@@ -15,3 +15,3 @@ "use strict";

const files_js_1 = require("../configs/files.js");
const cpus_js_1 = require("../polyfills/cpus.js");
const os_js_1 = require("../polyfills/os.js");
const startWatch = async (dirs, options) => {

@@ -30,9 +30,7 @@ let isRunning = false;

const listenStdin = async (input) => {
if (isRunning || executing.size > 0) {
if (isRunning || executing.size > 0)
return;
}
if (String(input).trim() === 'rs') {
for (const watcher of watchers) {
for (const watcher of watchers)
watcher.stop();
}
watchers.clear();

@@ -52,5 +50,4 @@ resultsClear();

const filePath = (0, map_tests_js_1.normalizePath)(file);
if (executing.has(filePath) || isRunning || executing.size > 0) {
if (executing.has(filePath) || isRunning || executing.size > 0)
return;
}
setIsRunning(true);

@@ -60,8 +57,7 @@ executing.add(filePath);

const tests = mappedTests.get(filePath);
if (!tests) {
if (!tests)
return;
}
await (0, poku_js_1.poku)(Array.from(tests), {
...options,
concurrency: (_a = options.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1),
concurrency: (_a = options.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, os_js_1.availableParallelism)() / 2), 1),
});

@@ -79,14 +75,11 @@ setTimeout(() => {

if (event === 'change') {
if (executing.has(file) || isRunning || executing.size > 0) {
if (executing.has(file) || isRunning || executing.size > 0)
return;
}
setIsRunning(true);
executing.add(file);
resultsClear();
(0, poku_js_1.poku)(file, options).then(() => {
setTimeout(() => {
executing.delete(file);
setIsRunning(false);
}, interval);
});
(0, poku_js_1.poku)(file, options).then(() => setTimeout(() => {
executing.delete(file);
setIsRunning(false);
}, interval));
}

@@ -93,0 +86,0 @@ });

@@ -7,55 +7,29 @@ "use strict";

const createAssert = (nodeAssert) => {
const ok = (value, message) => {
(0, assert_js_1.processAssert)(() => {
nodeAssert.ok(value);
}, { message });
};
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 });
(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,
});
};
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,
});
const fail = (message) => {
(0, assert_js_1.processAssert)(() => {
nodeAssert.fail(message);
}, {
(0, assert_js_1.processAssert)(() => nodeAssert.fail(message), {
message,

@@ -71,5 +45,4 @@ defaultMessage: 'Test failed intentionally',

errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
typeof errorOrMessage === 'object')
nodeAssert.doesNotThrow(block, errorOrMessage, message);
}
else {

@@ -89,3 +62,3 @@ const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;

errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
typeof errorOrMessage === 'object')
(0, assert_js_1.processAssert)(() => nodeAssert.throws(block, errorOrMessage), {

@@ -96,3 +69,2 @@ message,

});
}
else {

@@ -111,5 +83,4 @@ const msg = typeof errorOrMessage !== 'undefined' ? errorOrMessage : message;

errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
typeof errorOrMessage === 'object')
await nodeAssert.rejects(block, errorOrMessage, message);
}
else {

@@ -130,8 +101,6 @@ const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;

errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
typeof errorOrMessage === 'object')
await nodeAssert.doesNotReject(block, errorOrMessage, message);
}
else {
else
await nodeAssert.doesNotReject(block, message);
}
}, {

@@ -146,5 +115,4 @@ message: typeof errorOrMessage === 'string' ? errorOrMessage : message,

if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12) {
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), {

@@ -159,5 +127,4 @@ message,

if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12) {
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), {

@@ -164,0 +131,0 @@ message,

import type { Code } from '../../@types/code.js';
import type { Configs } from '../../@types/poku.js';
export declare const onSigint: () => void;
export declare const onSigint: () => boolean;
export declare function poku(targetPaths: string | string[], configs: Configs & {

@@ -5,0 +5,0 @@ noExit: true;

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

const onSigint = () => {
node_process_1.default.stdout.write('\u001B[?25h');
};
const onSigint = () => node_process_1.default.stdout.write('\u001B[?25h');
exports.onSigint = onSigint;

@@ -34,10 +32,8 @@ node_process_1.default.once('SIGINT', exports.onSigint);

code = 1;
if (configs === null || configs === void 0 ? void 0 : configs.failFast) {
if (configs === null || configs === void 0 ? void 0 : configs.failFast)
break;
}
}
}
if (configs === null || configs === void 0 ? void 0 : configs.noExit) {
if (configs === null || configs === void 0 ? void 0 : configs.noExit)
return code;
}
const end = node_process_1.default.hrtime(start);

@@ -58,11 +54,9 @@ const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);

const result = await (0, run_tests_js_1.runTestsParallel)(dir, configs);
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast)) {
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast))
throw new Error('quiet');
}
return result;
});
const concurrency = await Promise.all(promises);
if (concurrency.some((result) => !result)) {
if (concurrency.some((result) => !result))
code = 1;
}
}

@@ -77,6 +71,5 @@ catch (_a) {

showLogs && (0, format_js_1.showTestResults)();
if (configs === null || configs === void 0 ? void 0 : configs.noExit) {
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);
}

@@ -12,3 +12,3 @@ import type { End, StartScriptOptions, StartServiceOptions } from '../../@types/background-process.js';

*
* By default, it uses **npm**, but you can costumize it using the `runner` option.
* By default it uses **npm**, but you can costumize it using the `runner` option.
*/

@@ -15,0 +15,0 @@ export declare const startScript: (script: string, options?: StartScriptOptions) => Promise<{

@@ -39,8 +39,6 @@ "use strict";

if (['bun', 'deno'].includes(runtime) ||
['bun', 'deno'].includes(String(options === null || options === void 0 ? void 0 : options.runner))) {
['bun', 'deno'].includes(String(options === null || options === void 0 ? void 0 : options.runner)))
node_process_1.default.kill(PID);
}
else {
else
node_process_1.default.kill(-PID, 'SIGKILL');
}
if (port && ['bun', 'deno'].includes(runtime)) {

@@ -95,5 +93,4 @@ setTimeout(async () => {

service.on('close', (code) => {
if (code !== 0) {
if (code !== 0)
reject(`Service exited with code ${code}`);
}
});

@@ -106,3 +103,3 @@ const timeout = setTimeout(() => {

}, (options === null || options === void 0 ? void 0 : options.timeout) || 60000);
if (typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'number') {
if (typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'number')
setTimeout(() => {

@@ -115,3 +112,2 @@ if (!isResolved) {

}, options.startAfter);
}
}

@@ -134,6 +130,7 @@ catch (_a) { }

*
* By default, it uses **npm**, but you can costumize it using the `runner` option.
* By default it uses **npm**, but you can costumize it using the `runner` option.
*/
const startScript = async (script, options) => {
const runner = (options === null || options === void 0 ? void 0 : options.runner) || 'npm';
var _a;
const runner = (_a = options === null || options === void 0 ? void 0 : options.runner) !== null && _a !== void 0 ? _a : 'npm';
const runtimeOptions = (0, get_runner_js_1.scriptRunner)(runner);

@@ -149,5 +146,4 @@ const runtime = runtimeOptions.shift();

node_process_1.default.once('SIGINT', async () => {
for (const { end, port } of runningProcesses.values()) {
for (const { end, port } of runningProcesses.values())
await end(port);
}
});

@@ -8,4 +8,5 @@ import type { DescribeOptions } from '../../@types/describe.js';

export declare const describe: typeof describeCore & {
todo: (message: string, _cb?: () => unknown) => void;
todo: (message: string, _cb?: () => unknown) => boolean;
skip: (message: string, _cb?: () => unknown) => boolean;
};
export {};

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

const todo_js_1 = require("./it/todo.js");
const skip_js_1 = require("./it/skip.js");
async function describeCore(arg1, arg2) {

@@ -18,8 +19,6 @@ let title;

title = arg1;
if (typeof arg2 === 'function') {
if (typeof arg2 === 'function')
cb = arg2;
}
else {
else
options = arg2;
}
}

@@ -32,29 +31,26 @@ else if (typeof arg1 === 'function') {

indentation_js_1.indentation.hasDescribe = true;
const { background, icon } = options || {};
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 { background, icon } = options !== null && options !== void 0 ? options : {};
const message = `${cb ? (0, format_js_1.format)('◌').dim() : (icon !== null && icon !== void 0 ? 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) {
if (noBackground)
write_js_1.Write.log((0, format_js_1.format)(message).bold());
}
else {
else
write_js_1.Write.log((0, format_js_1.format)(` ${message} `).bg(typeof background === 'string' ? background : 'grey'));
}
}
if (typeof cb !== 'function') {
if (typeof cb !== 'function')
return;
}
const start = (0, node_process_1.hrtime)();
const resultCb = cb();
if (resultCb instanceof Promise) {
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()}`);
}
if (!title)
return;
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()}`);
}
exports.describe = Object.assign(describeCore, {
todo: todo_js_1.todo,
skip: skip_js_1.skip,
});

@@ -25,5 +25,4 @@ "use strict";

each_js_1.each.before.cb = () => {
if (each_js_1.each.before.status) {
if (each_js_1.each.before.status)
return callback();
}
};

@@ -61,5 +60,4 @@ const pause = () => {

each_js_1.each.after.cb = () => {
if (each_js_1.each.after.status) {
if (each_js_1.each.after.status)
return callback();
}
};

@@ -66,0 +64,0 @@ const pause = () => {

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

}
for (const [arg, value] of mapEnv) {
for (const [arg, value] of mapEnv)
node_process_1.env[arg] = value;
}
};
exports.envFile = envFile;

@@ -24,8 +24,6 @@ "use strict";

message += `${(0, format_js_1.format)(success).bg('green')} ${(0, format_js_1.format)(failure).bg(poku_js_1.results.fail === 0 ? 'grey' : 'brightRed')}`;
if (poku_js_1.results.skip) {
if (poku_js_1.results.skip)
message += ` ${(0, format_js_1.format)(skips).bg('brightBlue')}`;
}
if (poku_js_1.results.todo) {
if (poku_js_1.results.todo)
message += ` ${(0, format_js_1.format)(plans).bg('brightBlue')}`;
}
}

@@ -59,13 +57,11 @@ else {

node_process_1.default.on('unhandledRejection', (err) => {
if (!(err instanceof node_assert_1.AssertionError)) {
if (!(err instanceof node_assert_1.AssertionError))
console.error('unhandledRejection', err);
}
node_process_1.default.exitCode = 1;
});
node_process_1.default.on('uncaughtException', (err) => {
if (!(err instanceof node_assert_1.AssertionError)) {
if (!(err instanceof node_assert_1.AssertionError))
console.error('uncaughtException', err);
}
node_process_1.default.exitCode = 1;
});

@@ -6,4 +6,5 @@ declare function itCore(message: string, cb: () => Promise<unknown>): Promise<void>;

export declare const it: typeof itCore & {
todo: (message: string, _cb?: () => unknown) => void;
todo: (message: string, _cb?: () => unknown) => boolean;
skip: (message: string, _cb?: () => unknown) => boolean;
};
export {};

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

const todo_js_1 = require("./todo.js");
const skip_js_1 = require("./skip.js");
async function itCore(...args) {

@@ -21,5 +22,4 @@ try {

}
else {
else
cb = args[0];
}
if (message) {

@@ -33,23 +33,20 @@ indentation_js_1.indentation.hasItOrTest = true;

const beforeResult = each_js_1.each.before.cb();
if (beforeResult instanceof Promise) {
if (beforeResult instanceof Promise)
await beforeResult;
}
}
const start = (0, node_process_1.hrtime)();
const resultCb = cb();
if (resultCb instanceof Promise) {
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();
if (afterResult instanceof Promise) {
if (afterResult instanceof Promise)
await afterResult;
}
}
if (message) {
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
indentation_js_1.indentation.hasItOrTest = 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)
return;
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
indentation_js_1.indentation.hasItOrTest = 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()}`);
}

@@ -60,5 +57,4 @@ catch (error) {

const afterResult = each_js_1.each.after.cb();
if (afterResult instanceof Promise) {
if (afterResult instanceof Promise)
await afterResult;
}
}

@@ -70,2 +66,3 @@ throw error;

todo: todo_js_1.todo,
skip: skip_js_1.skip,
});

@@ -1,1 +0,1 @@

export declare const todo: (message: string, _cb?: () => unknown) => void;
export declare const todo: (message: string, _cb?: () => unknown) => boolean;

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

const format_js_1 = require("../../../services/format.js");
const todo = (message, _cb) => {
write_js_1.Write.log(`${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`● ${message}`).cyan().bold()}`);
};
const todo = (message, _cb) => write_js_1.Write.log(`${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`● ${message}`).cyan().bold()}`);
exports.todo = todo;

@@ -18,5 +18,4 @@ "use strict";

for (const PID of PIDs) {
if (!PID) {
if (!PID)
continue;
}
await killPID(PID);

@@ -28,5 +27,4 @@ }

for (const PID of PIDs) {
if (!PID) {
if (!PID)
continue;
}
await killPID(PID);

@@ -33,0 +31,0 @@ }

@@ -39,3 +39,3 @@ "use strict";

isFullPath = true;
return Array.prototype.concat((0, exports.sanitizePath)(dirPath));
return [(0, exports.sanitizePath)(dirPath)];
}

@@ -58,21 +58,15 @@ return await (0, fs_js_1.readdir)((0, exports.sanitizePath)(dirPath));

if (fullPath.indexOf('node_modules') !== -1 ||
fullPath.indexOf('.git/') !== -1) {
fullPath.indexOf('.git/') !== -1)
return;
}
if (isFullPath && (files_js_1.states === null || files_js_1.states === void 0 ? void 0 : files_js_1.states.isSinglePath)) {
if (isFullPath && (files_js_1.states === null || files_js_1.states === void 0 ? void 0 : files_js_1.states.isSinglePath))
return files.add(fullPath);
}
if (exclude) {
if (exclude)
for (const pattern of exclude) {
if (pattern.test(fullPath)) {
if (pattern.test(fullPath))
return;
}
}
}
if (filter.test(fullPath)) {
if (filter.test(fullPath))
return files.add(fullPath);
}
if (stat.isDirectory()) {
if (stat.isDirectory())
await (0, exports.getAllFiles)(fullPath, files, configs);
}
}));

@@ -79,0 +73,0 @@ return files;

@@ -10,3 +10,3 @@ "use strict";

const FILE = node_process_1.env.FILE;
if (message) {
if (message)
write_js_1.Write.log((0, format_js_1.format)(isPoku

@@ -17,5 +17,4 @@ ? `◯ ${message} ${(0, format_js_1.format)('›').dim()} ${(0, format_js_1.format)(`${FILE}`).italic().gray().dim()}`

.bold());
}
(0, node_process_1.exit)(0);
};
exports.skip = skip;

@@ -7,3 +7,4 @@ export declare const test: {

} & {
todo: (message: string, _cb?: () => unknown) => void;
todo: (message: string, _cb?: () => unknown) => boolean;
skip: (message: string, _cb?: () => unknown) => boolean;
};

@@ -12,11 +12,8 @@ "use strict";

});
client.on('error', () => {
resolve(false);
});
client.on('error', () => resolve(false));
});
/** Wait until the defined milliseconds. */
const sleep = (milliseconds) => {
if (!Number.isInteger(milliseconds)) {
if (!Number.isInteger(milliseconds))
throw new Error('Milliseconds must be an integer.');
}
return new Promise((resolve) => setTimeout(resolve, milliseconds));

@@ -30,14 +27,10 @@ };

const timeout = (options === null || options === void 0 ? void 0 : options.timeout) || 60000;
if (typeof callback !== 'function') {
if (typeof callback !== 'function')
throw new Error('Callback must be a function.');
}
if (!Number.isInteger(interval)) {
if (!Number.isInteger(interval))
throw new Error('Interval must be an integer.');
}
if (!Number.isInteger(timeout)) {
if (!Number.isInteger(timeout))
throw new Error('Timeout must be an integer.');
}
if (!Number.isInteger(delay)) {
if (!Number.isInteger(delay))
throw new Error('Delay must be an integer.');
}
await (0, exports.sleep)(delay);

@@ -48,11 +41,9 @@ const startTime = Date.now();

if (typeof expectedResult === 'function') {
if (typeof result === 'function' && result.name === expectedResult.name) {
if (typeof result === 'function' && result.name === expectedResult.name)
break;
}
}
else if (typeof expectedResult === 'symbol') {
if (typeof result === 'symbol' &&
String(result) === String(expectedResult)) {
String(result) === String(expectedResult))
break;
}
}

@@ -68,5 +59,4 @@ else {

}
if (Date.now() - startTime >= timeout) {
if (Date.now() - startTime >= timeout)
throw new Error('Timeout');
}
await (0, exports.sleep)(interval);

@@ -80,7 +70,6 @@ }

const host = (options === null || options === void 0 ? void 0 : options.host) || 'localhost';
if (!Number.isInteger(port)) {
if (!Number.isInteger(port))
throw new Error('Port must be an integer.');
}
await (0, exports.waitForExpectedResult)(async () => await checkPort(port, host), true, options);
};
exports.waitForPort = waitForPort;

@@ -5,33 +5,20 @@ "use strict";

const object_js_1 = require("../polyfills/object.js");
const get_runtime_js_1 = require("./get-runtime.js");
const recurse = (value) => {
if (typeof value === 'undefined' ||
typeof value === 'function' ||
typeof value === 'bigint' ||
typeof value === 'symbol' ||
value instanceof RegExp)
return String(value);
if (Array.isArray(value))
return value.map(recurse);
if (value instanceof Set)
return Array.from(value).map(recurse);
if (value instanceof Map)
return recurse((0, object_js_1.fromEntries)(value));
if (value !== null && typeof value === 'object')
return (0, object_js_1.fromEntries)((0, object_js_1.entries)(value).map(([key, val]) => [key, recurse(val)]));
return value;
};
const parseResultType = (type) => {
const recurse = (value) => {
if (typeof value === 'undefined' ||
typeof value === 'function' ||
typeof value === 'bigint' ||
typeof value === 'symbol' ||
value instanceof RegExp) {
return String(value);
}
if (Array.isArray(value)) {
return value.map(recurse);
}
if (value instanceof Set) {
return Array.from(value).map(recurse);
}
if (value instanceof Map) {
return recurse(!get_runtime_js_1.nodeVersion || get_runtime_js_1.nodeVersion >= 12
? Object.fromEntries(value)
: (0, object_js_1.fromEntries)(value));
}
if (value !== null && typeof value === 'object') {
if (!get_runtime_js_1.nodeVersion || get_runtime_js_1.nodeVersion >= 12) {
return Object.fromEntries(Object.entries(value).map(([key, val]) => [key, recurse(val)]));
}
return (0, object_js_1.fromEntries)((0, object_js_1.entries)(value).map(([key, val]) => [key, recurse(val)]));
}
return value;
};
const result = recurse(type);

@@ -38,0 +25,0 @@ return typeof result === 'string' ? result : JSON.stringify(result, null, 2);

@@ -6,18 +6,18 @@ "use strict";

const findFile = (error) => {
var _a;
const stackLines = ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n')) || [];
var _a, _b;
const stackLines = (_b = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n')) !== null && _b !== void 0 ? _b : [];
let file = '';
const basePath = 'poku/lib/';
for (const line of stackLines) {
if (line.indexOf(basePath) === -1) {
const match = line.match(regex);
if (match === null || match === void 0 ? void 0 : match[1]) {
file = match[1];
break;
}
if (match === null || match === void 0 ? void 0 : match[3]) {
file = match[3];
break;
}
if (line.indexOf(basePath) !== -1)
continue;
const match = line.match(regex);
if (match === null || match === void 0 ? void 0 : match[1]) {
file = match[1];
break;
}
if (match === null || match === void 0 ? void 0 : match[3]) {
file = match[3];
break;
}
}

@@ -24,0 +24,0 @@ return file;

@@ -12,12 +12,8 @@ "use strict";

const argValue = baseArgs.find((a) => a.startsWith(argPattern));
if (!argValue) {
return undefined;
}
if (!argValue)
return;
return argValue.slice(argPattern.length).replace(regexQuotes, '');
};
exports.getArg = getArg;
const hasArg = (arg, prefix = '--', baseArgs = processedArgs) => {
const argPattern = `${prefix}${arg}`;
return baseArgs.some((a) => a.startsWith(argPattern));
};
const hasArg = (arg, prefix = '--', baseArgs = processedArgs) => baseArgs.some((a) => a.startsWith(`${prefix}${arg}`));
exports.hasArg = hasArg;

@@ -28,9 +24,8 @@ const getPaths = (prefix = '--', baseArgs = processedArgs) => {

for (const arg of baseArgs) {
if (!arg.startsWith(prefix)) {
hasPaths = true;
const parts = arg.split(',');
for (const part of parts) {
paths.push(part);
}
}
if (arg.startsWith(prefix))
continue;
hasPaths = true;
const parts = arg.split(',');
for (const part of parts)
paths.push(part);
}

@@ -42,9 +37,7 @@ return hasPaths ? paths : undefined;

const hasArgument = (0, exports.hasArg)(arg, prefix, baseArgs);
if (!hasArgument) {
return undefined;
}
if (!hasArgument)
return;
const argValue = (0, exports.getArg)(arg, prefix, baseArgs);
if (!argValue) {
if (!argValue)
return [];
}
return argValue

@@ -51,0 +44,0 @@ .split(',')

@@ -11,5 +11,4 @@ "use strict";

const runtime = (0, get_runtime_js_1.getRuntime)(configs);
if (runtime === 'bun') {
if (runtime === 'bun')
return ['bun'];
}
if (runtime === 'deno') {

@@ -41,16 +40,12 @@ const denoAllow = ((_a = configs === null || configs === void 0 ? void 0 : configs.deno) === null || _a === void 0 ? void 0 : _a.allow)

const scriptRunner = (runner) => {
if (runner === 'bun') {
return ['bun', 'run'];
}
if (runner === 'deno') {
return ['deno', 'task'];
}
if (runner === 'yarn') {
return ['yarn'];
}
if (runner === 'pnpm') {
return ['pnpm', 'run'];
}
return [exports.isWindows ? 'npm.cmd' : 'npm', 'run'];
var _a;
const commands = {
npm: [exports.isWindows ? 'npm.cmd' : 'npm', 'run'],
bun: ['bun', 'run'],
deno: ['deno', 'task'],
yarn: ['yarn'],
pnpm: ['pnpm', 'run'],
};
return (_a = commands === null || commands === void 0 ? void 0 : commands[runner]) !== null && _a !== void 0 ? _a : commands['npm'];
};
exports.scriptRunner = scriptRunner;

@@ -1,5 +0,5 @@

import type { Configs } from '../@types/poku.js';
export declare const supportedPlatforms: readonly Configs['platform'][];
import type { Configs, Runtime } from '../@types/poku.js';
export declare const supportedPlatforms: readonly Runtime[];
export declare const platformIsValid: (platform: unknown) => platform is (typeof supportedPlatforms)[number];
export declare const getRuntime: (configs?: Configs) => (typeof supportedPlatforms)[number];
export declare const nodeVersion: number | undefined;

@@ -7,25 +7,13 @@ "use strict";

const regex = /v(\d+)\./;
exports.supportedPlatforms = [
'node',
'bun',
'deno',
];
const platformIsValid = (platform) => {
if (typeof platform === 'string' &&
exports.supportedPlatforms.some((supportedPlatform) => supportedPlatform === platform)) {
return true;
}
return false;
};
exports.supportedPlatforms = ['node', 'bun', 'deno'];
const platformIsValid = (platform) => typeof platform === 'string' &&
exports.supportedPlatforms.indexOf(platform) > -1;
exports.platformIsValid = platformIsValid;
const getRuntime = (configs) => {
if ((configs === null || configs === void 0 ? void 0 : configs.platform) && (0, exports.platformIsValid)(configs.platform)) {
if ((configs === null || configs === void 0 ? void 0 : configs.platform) && (0, exports.platformIsValid)(configs.platform))
return configs.platform;
}
if (typeof Deno !== 'undefined') {
if (typeof Deno !== 'undefined')
return 'deno';
}
if (typeof Bun !== 'undefined') {
if (typeof Bun !== 'undefined')
return 'bun';
}
return 'node';

@@ -32,0 +20,0 @@ };

@@ -21,5 +21,4 @@ "use strict";

try {
if (filePath.endsWith('.js') || filePath.endsWith('.cjs')) {
if (filePath.endsWith('.js') || filePath.endsWith('.cjs'))
return require(`file://${(0, node_path_1.normalize)(filePath)}`);
}
const configsFile = await (0, fs_js_1.readFile)(filePath, 'utf8');

@@ -26,0 +25,0 @@ return jsonc_js_1.JSONC.parse(configsFile);

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

const regex = {
newLine: /\n/,
ansi: /u001b\[0m|\n/i,

@@ -19,24 +18,20 @@ skip: /\\u001b\[94m\\u001b\[1m◯/i,

const normalizedOutput = JSON.stringify(output);
if (regex.skip.test(normalizedOutput)) {
if (regex.skip.test(normalizedOutput))
++poku_js_1.results.skip;
}
if (regex.todo.test(normalizedOutput)) {
if (regex.todo.test(normalizedOutput))
++poku_js_1.results.todo;
}
const debug = (0, exports.isDebug)(configs);
const pad = (configs === null || configs === void 0 ? void 0 : configs.parallel) ? ' ' : ' ';
const splittedOutput = output.split(regex.newLine);
const splittedOutput = output.split('\n');
const outputs = (debug || !result
? splittedOutput
: splittedOutput.filter((current) => {
if (current.indexOf('Exited with code') !== -1) {
if (current.indexOf('Exited with code') !== -1)
return false;
}
return regex.ansi.test(JSON.stringify(current)) || current === '';
})).filter((line) => (line === null || line === void 0 ? void 0 : line.trim().length) > 0);
if (outputs.length === 0) {
if (outputs.length === 0)
return;
}
return outputs.map((current) => `${pad}${current}`);
};
exports.parserOutput = parserOutput;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseTimeToSecs = exports.parseTime = void 0;
const pad = (num) => String(num).padStart(2, '0');
const parseTime = (date) => {
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const seconds = date.getSeconds().toString().padStart(2, '0');
const hours = pad(date.getHours());
const minutes = pad(date.getMinutes());
const seconds = pad(date.getSeconds());
return `${hours}:${minutes}:${seconds}`;

@@ -12,6 +13,5 @@ };

const parseTimeToSecs = (milliseconds) => {
const ms = Number.parseFloat(milliseconds);
const seconds = (ms / 1000).toFixed(2);
return seconds;
const ms = Number(milliseconds);
return (ms / 1000).toFixed(2);
};
exports.parseTimeToSecs = parseTimeToSecs;

@@ -6,14 +6,9 @@ "use strict";

const toDynamicCase = (str) => {
if (str[1] !== '-') {
return str;
}
if (str[1] !== '-')
return str;
const [flag, ...args] = str.slice(2).split('=');
const dynamicCase = flag.toLowerCase().replace(regex, '');
let processArg = `--${dynamicCase}`;
if (args.length > 0) {
processArg += `=${args.join('=')}`;
}
return processArg;
const formattedArg = args.length > 0 ? `=${args.join('=')}` : '';
return `--${dynamicCase}${formattedArg}`;
};
exports.toDynamicCase = toDynamicCase;

@@ -28,5 +28,4 @@ "use strict";

if (inString) {
if (char === '"' && content[i - 1] !== '\\') {
if (char === '"' && content[i - 1] !== '\\')
inString = false;
}
result += char;

@@ -46,5 +45,4 @@ continue;

if (char === '/' && content[i + 1] === '/') {
while (i < length && content[i] !== '\n') {
while (i < length && content[i] !== '\n')
i++;
}
continue;

@@ -51,0 +49,0 @@ }

@@ -1,4 +0,12 @@

export declare const entries: (obj: {
[key: string]: any;
}) => [string, unknown][];
export declare const fromEntries: (entries: [string, unknown][] | Map<string, unknown>) => Record<string, unknown>;
export declare const entries: {
<T>(o: {
[s: string]: T;
} | ArrayLike<T>): [string, T][];
(o: {}): [string, any][];
};
export declare const fromEntries: {
<T = any>(entries: Iterable<readonly [PropertyKey, T]>): {
[k: string]: T;
};
(entries: Iterable<readonly any[]>): any;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromEntries = exports.entries = void 0;
const entries = (obj) => {
const ownProps = Object.keys(obj);
let i = ownProps.length;
const resArray = new Array(i);
while (i--) {
resArray[i] = [ownProps[i], obj[ownProps[i]]];
const get_runtime_js_1 = require("../parsers/get-runtime.js");
const needsPolyfill = get_runtime_js_1.nodeVersion && get_runtime_js_1.nodeVersion < 12;
exports.entries = needsPolyfill
? (obj) => {
const ownProps = Object.keys(obj);
let i = ownProps.length;
const resArray = new Array(i);
while (i--)
resArray[i] = [ownProps[i], obj[ownProps[i]]];
return resArray;
}
return resArray;
};
exports.entries = entries;
const fromEntries = (entries) => {
const mappedEntries = entries instanceof Map ? Array.from(entries) : entries;
return mappedEntries.reduce((acc, [key, value]) => {
acc[key] = value;
return acc;
}, {});
};
exports.fromEntries = fromEntries;
: Object.entries;
exports.fromEntries = needsPolyfill
? (entries) => {
const mappedEntries = entries instanceof Map ? Array.from(entries) : entries;
return mappedEntries.reduce((acc, [key, value]) => {
acc[key] = value;
return acc;
}, {});
}
: Object.fromEntries;

@@ -25,8 +25,6 @@ "use strict";

if (typeof options.message === 'string') {
if (indentation_js_1.indentation.hasDescribe) {
if (indentation_js_1.indentation.hasDescribe)
preIdentation += ' ';
}
if (indentation_js_1.indentation.hasItOrTest) {
if (indentation_js_1.indentation.hasItOrTest)
preIdentation += ' ';
}
const message = isPoku && !indentation_js_1.indentation.hasDescribe && !indentation_js_1.indentation.hasItOrTest

@@ -40,2 +38,3 @@ ? `${preIdentation}${(0, format_js_1.format)(`${(0, format_js_1.format)(`✔ ${options.message}`).bold()} ${(0, format_js_1.format)(`› ${FILE}`).success().dim()}`).success()}`

const handleError = (error, options) => {
var _a, _b;
node_process_1.default.exitCode = 1;

@@ -46,18 +45,13 @@ if (error instanceof node_assert_1.AssertionError) {

const file = node_path_1.default.relative(node_path_1.default.resolve(cwd), absolutePath);
if (indentation_js_1.indentation.hasDescribe) {
if (indentation_js_1.indentation.hasDescribe)
preIdentation += ' ';
}
if (indentation_js_1.indentation.hasItOrTest) {
if (indentation_js_1.indentation.hasItOrTest)
preIdentation += ' ';
}
let message = '';
if (typeof options.message === 'string') {
if (typeof options.message === 'string')
message = options.message;
}
else if (options.message instanceof Error) {
else if (options.message instanceof Error)
message = options.message.message;
}
else if (typeof options.defaultMessage === 'string') {
else if (typeof options.defaultMessage === 'string')
message = options.defaultMessage;
}
const finalMessage = (message === null || message === void 0 ? void 0 : message.trim().length) > 0

@@ -76,10 +70,8 @@ ? (0, format_js_1.format)(`✘ ${message}`).fail().bold()

const splitExpected = (0, assert_js_1.parseResultType)(expected).split('\n');
write_js_1.Write.log((0, format_js_1.format)(`${preIdentation} ${(options === null || options === void 0 ? void 0 : options.actual) || 'Actual'}:`).dim());
for (const line of splitActual) {
write_js_1.Write.log((0, format_js_1.format)(`${preIdentation} ${(_a = options === null || options === void 0 ? void 0 : options.actual) !== null && _a !== void 0 ? _a : 'Actual'}:`).dim());
for (const line of splitActual)
write_js_1.Write.log(`${preIdentation} ${(0, format_js_1.format)(line).fail().bold()}`);
}
write_js_1.Write.log(`\n${preIdentation} ${(0, format_js_1.format)(`${(options === null || options === void 0 ? void 0 : options.expected) || 'Expected'}:`).dim()}`);
for (const line of splitExpected) {
write_js_1.Write.log(`\n${preIdentation} ${(0, format_js_1.format)(`${(_b = options === null || options === void 0 ? void 0 : options.expected) !== null && _b !== void 0 ? _b : 'Expected'}:`).dim()}`);
for (const line of splitExpected)
write_js_1.Write.log(`${preIdentation} ${(0, format_js_1.format)(line).success().bold()}`);
}
preIdentation = '';

@@ -91,5 +83,4 @@ }

}
if (isPoku) {
if (isPoku)
throw error;
}
}

@@ -96,0 +87,0 @@

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

}
dockerProcess.on('close', (code) => {
resolve(code === 0);
});
dockerProcess.on('error', () => {
resolve(false);
});
dockerProcess.on('close', (code) => resolve(code === 0));
dockerProcess.on('error', () => resolve(false));
});

@@ -36,5 +32,5 @@ };

this.context = context || '.';
this.ports = ports || [];
this.ports = ports !== null && ports !== void 0 ? ports : [];
this.cache = cache;
this.environments = environments || [];
this.environments = environments !== null && environments !== void 0 ? environments : [];
this.envFile = envFile;

@@ -47,5 +43,4 @@ this.detach = detach;

const args = ['build'];
if (this.cache === false) {
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);

@@ -57,11 +52,8 @@ }

args.push(...['--name', this.containerName]);
for (const port of this.ports) {
for (const port of this.ports)
args.push(...['-p', port]);
}
for (const environment of this.environments) {
for (const environment of this.environments)
args.push(...['-e', environment]);
}
if (this.envFile) {
if (this.envFile)
args.push(...['--env-file', this.envFile]);
}
return await runDockerCommand('docker', [...args, this.tagName], { cwd: this.cwd }, this.verbose);

@@ -81,3 +73,3 @@ }

const { file, projectName, build, serviceName, envFile, detach, cwd, verbose, } = configs;
this.file = file || './docker-compose.yml';
this.file = file !== null && file !== void 0 ? file : './docker-compose.yml';
this.build = build;

@@ -93,16 +85,12 @@ this.serviceName = serviceName;

const args = ['compose', '-f', this.file];
if (this.envFile) {
if (this.envFile)
args.push(...['--env-file', this.envFile]);
}
if (this.projectName) {
if (this.projectName)
args.push(...['-p', this.projectName]);
}
args.push('up');
args.push(this.detach !== false ? '-d' : '--abort-on-container-exit');
if (this.build) {
if (this.build)
args.push('--build');
}
if (this.serviceName) {
if (this.serviceName)
args.push(this.serviceName);
}
return await runDockerCommand('docker', args, { cwd: this.cwd }, this.verbose);

@@ -112,8 +100,6 @@ }

const args = ['-f', this.file];
if (this.envFile) {
if (this.envFile)
args.push(...['--env-file', this.envFile]);
}
if (this.projectName) {
if (this.projectName)
args.push(...['-p', this.projectName]);
}
return await runDockerCommand('docker', ['compose', ...args, 'down'], { cwd: this.cwd }, this.verbose);

@@ -120,0 +106,0 @@ }

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

const eachCore = async (type, fileRelative, configs) => {
if (typeof (configs === null || configs === void 0 ? void 0 : configs[type]) !== 'function') {
if (typeof (configs === null || configs === void 0 ? void 0 : configs[type]) !== 'function')
return true;
}
const cb = configs[type];

@@ -39,5 +38,4 @@ const showLogs = !(0, output_js_1.isQuiet)(configs);

const beforeEach = async (fileRelative, configs) => {
if (configs === null || configs === void 0 ? void 0 : configs.beforeEach) {
if (configs === null || configs === void 0 ? void 0 : configs.beforeEach)
return await eachCore('beforeEach', fileRelative, configs);
}
return true;

@@ -47,7 +45,6 @@ };

const afterEach = async (fileRelative, configs) => {
if (configs === null || configs === void 0 ? void 0 : configs.afterEach) {
if (configs === null || configs === void 0 ? void 0 : configs.afterEach)
return await eachCore('afterEach', fileRelative, configs);
}
return true;
};
exports.afterEach = afterEach;

@@ -12,5 +12,4 @@ "use strict";

output += char;
if (char === quoteChar && input[i - 1] !== '\\') {
if (char === quoteChar && input[i - 1] !== '\\')
inQuote = false;
}
}

@@ -22,8 +21,6 @@ else if (char === '"' || char === "'") {

}
else if (char === '#') {
else if (char === '#')
break;
}
else {
else
output += char;
}
}

@@ -35,5 +32,4 @@ return output.trim();

const index = line.indexOf('=');
if (index === -1) {
if (index === -1)
return null;
}
const arg = line.substring(0, index).trim();

@@ -48,2 +44,3 @@ const value = line

const resolveEnvVariables = (str, env) => {
var _a;
let result = '';

@@ -60,3 +57,3 @@ let i = 0;

i++;
result += env[varName] || '';
result += (_a = env[varName]) !== null && _a !== void 0 ? _a : '';
}

@@ -63,0 +60,0 @@ else {

@@ -22,2 +22,3 @@ export declare const backgroundColor: {

constructor(text: string);
private code;
static create(text: string): Formatter;

@@ -24,0 +25,0 @@ counter(current: number, total: number, pad?: string): this;

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

};
const ESC = '\x1b[';
class Formatter {

@@ -30,2 +31,6 @@ constructor(text) {

}
code(code) {
this.parts += `${ESC}${code}m`;
return this;
}
static create(text) {

@@ -36,48 +41,37 @@ return new Formatter(text);

const totalDigits = String(total).length;
const formattedCounter = String(current).padStart(totalDigits, pad);
this.parts += formattedCounter;
this.parts += String(current).padStart(totalDigits, pad);
return this;
}
dim() {
this.parts += '\x1b[2m';
return this;
return this.code('2');
}
bold() {
this.parts += '\x1b[1m';
return this;
return this.code('1');
}
underline() {
this.parts += '\x1b[4m';
return this;
return this.code('4');
}
info() {
this.parts += '\x1b[94m';
return this;
return this.code('94');
}
italic() {
this.parts += '\x1b[3m';
return this;
return this.code('3');
}
success() {
this.parts += '\x1b[32m';
return this;
return this.code('32');
}
fail() {
this.parts += '\x1b[91m';
return this;
return this.code('91');
}
gray() {
this.parts += '\x1b[90m';
return this;
return this.code('90');
}
cyan() {
this.parts += '\x1b[96m';
return this;
return this.code('96');
}
bg(color) {
this.parts += `\x1b[${exports.backgroundColor[color]}m\x1b[1m`;
return this;
return this.code(String(exports.backgroundColor[color])).bold();
}
[Symbol.toPrimitive]() {
return `${this.parts}${this.text}\x1b[0m`;
return `${this.parts}${this.text}${ESC}0m`;
}

@@ -84,0 +78,0 @@ }

@@ -29,5 +29,4 @@ "use strict";

const path = line.match(regex.dependecy);
if (path) {
if (path)
paths.add((0, exports.normalizePath)(path[1].replace(regex.extFilter, '')));
}
}

@@ -44,5 +43,4 @@ }

const normalizedFileWithExt = (0, exports.normalizePath)(fileWithExt);
if (normalizedFileWithExt.indexOf(normalizedSrcFile) !== -1) {
if (normalizedFileWithExt.indexOf(normalizedSrcFile) !== -1)
matchingFiles.add(fileWithExt);
}
}

@@ -58,3 +56,3 @@ }

const testPath = testPaths[index];
if (stat.isDirectory()) {
if (stat.isDirectory())
return (0, list_files_js_1.listFiles)(testPath, {

@@ -64,6 +62,4 @@ filter: testFilter,

});
}
if (stat.isFile() && regex.extFilter.test(testPath)) {
if (stat.isFile() && regex.extFilter.test(testPath))
return [testPath];
}
return [];

@@ -75,5 +71,4 @@ });

const processDeepImports = async (srcFile, testFile, intersectedSrcFiles) => {
if (processedFiles.has(srcFile)) {
if (processedFiles.has(srcFile))
return;
}
processedFiles.add(srcFile);

@@ -84,5 +79,4 @@ const srcContent = await (0, fs_js_1.readFile)(srcFile, 'utf8');

for (const deepImport of matchingFiles) {
if (!importMap.has(deepImport)) {
if (!importMap.has(deepImport))
importMap.set(deepImport, new Set());
}
importMap.get(deepImport).add((0, exports.normalizePath)(testFile));

@@ -103,5 +97,4 @@ await (0, exports.processDeepImports)(deepImport, testFile, intersectedSrcFiles);

content.indexOf(normalizedSrcFile) !== -1) {
if (!importMap.has(normalizedSrcFile)) {
if (!importMap.has(normalizedSrcFile))
importMap.set(normalizedSrcFile, new Set());
}
(_a = importMap.get(normalizedSrcFile)) === null || _a === void 0 ? void 0 : _a.add((0, exports.normalizePath)(testFile));

@@ -108,0 +101,0 @@ await (0, exports.processDeepImports)(srcFile, testFile, intersectedSrcFiles);

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

const service = (0, node_child_process_1.spawn)('kill', ['-9', String(Number(PID))]);
service.on('close', () => {
resolve(undefined);
});
service.on('close', () => resolve(undefined));
}),

@@ -33,5 +31,3 @@ windows: (PID) => new Promise((resolve) => {

]);
service.on('close', () => {
resolve(undefined);
});
service.on('close', () => resolve(undefined));
}),

@@ -52,10 +48,7 @@ };

for (const pid of output) {
if (pid) {
if (pid)
PIDs.add(Number(pid));
}
}
});
service.on('close', () => {
resolve(Array.from(PIDs));
});
service.on('close', () => resolve(Array.from(PIDs)));
}),

@@ -76,12 +69,9 @@ windows: (port) => new Promise((resolve) => {

const pid = Number(tokens[stateIndex + 1]);
if (!Number.isNaN(pid)) {
if (!Number.isNaN(pid))
PIDs.add(pid);
}
}
});
});
service.on('close', () => {
resolve(Array.from(PIDs));
});
service.on('close', () => resolve(Array.from(PIDs)));
}),
};

@@ -40,5 +40,4 @@ "use strict";

let end;
if (!(await (0, each_js_1.beforeEach)(fileRelative, configs))) {
if (!(await (0, each_js_1.beforeEach)(fileRelative, configs)))
return false;
}
return new Promise((resolve) => {

@@ -74,8 +73,6 @@ var _a;

const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
if (result) {
if (result)
files_js_1.fileResults.success.set(fileRelative, total);
}
else {
else
files_js_1.fileResults.fail.set(fileRelative, total);
}
resolve(result);

@@ -82,0 +79,0 @@ });

@@ -17,3 +17,3 @@ "use strict";

const poku_js_1 = require("../configs/poku.js");
const cpus_js_1 = require("../polyfills/cpus.js");
const os_js_1 = require("../polyfills/os.js");
const cwd = node_process_1.default.cwd();

@@ -73,13 +73,11 @@ const runTests = async (dir, configs) => {

const filesByConcurrency = [];
const concurrencyLimit = (_a = configs === null || configs === void 0 ? void 0 : configs.concurrency) !== null && _a !== void 0 ? _a : Math.max((0, cpus_js_1.availableParallelism)() - 1, 1);
const concurrencyLimit = (_a = configs === null || configs === void 0 ? void 0 : configs.concurrency) !== null && _a !== void 0 ? _a : Math.max((0, os_js_1.availableParallelism)() - 1, 1);
const concurrencyResults = [];
const showLogs = !(0, output_js_1.isQuiet)(configs);
if (concurrencyLimit > 0) {
for (let i = 0; i < files.length; i += concurrencyLimit) {
for (let i = 0; i < files.length; i += concurrencyLimit)
filesByConcurrency.push(files.slice(i, i + concurrencyLimit));
}
}
else {
else
filesByConcurrency.push(files);
}
try {

@@ -86,0 +84,0 @@ for (const fileGroup of filesByConcurrency) {

@@ -17,8 +17,5 @@ "use strict";

watchFile(filePath) {
if (this.fileWatchers.has(filePath)) {
if (this.fileWatchers.has(filePath))
return;
}
const watcher = (0, node_fs_1.watch)(filePath, (eventType) => {
this.callback(filePath, eventType);
});
const watcher = (0, node_fs_1.watch)(filePath, (eventType) => this.callback(filePath, eventType));
this.fileWatchers.set(filePath, watcher);

@@ -34,10 +31,8 @@ }

this.unwatchFiles();
for (const filePath of filePaths) {
for (const filePath of filePaths)
this.watchFile(filePath);
}
}
async watchDirectory(dir) {
if (this.dirWatchers.has(dir)) {
if (this.dirWatchers.has(dir))
return;
}
const watcher = (0, node_fs_1.watch)(dir, async (_, filename) => {

@@ -50,5 +45,4 @@ if (filename) {

const stats = await (0, fs_js_1.stat)(fullPath);
if (stats.isDirectory()) {
if (stats.isDirectory())
await this.watchDirectory(fullPath);
}
}

@@ -61,6 +55,6 @@ catch (_a) { }

for (const entry of entries) {
if (entry.isDirectory()) {
const fullPath = (0, node_path_1.join)(dir, entry.name);
await this.watchDirectory(fullPath);
}
if (!entry.isDirectory())
continue;
const fullPath = (0, node_path_1.join)(dir, entry.name);
await this.watchDirectory(fullPath);
}

@@ -74,6 +68,5 @@ }

await this.watchDirectory(this.rootDir);
return;
}
else {
this.watchFile(this.rootDir);
}
this.watchFile(this.rootDir);
}

@@ -80,0 +73,0 @@ stop() {

import type { Formatter } from '../services/format.js';
export declare const Write: {
readonly log: (data: string | Uint8Array | Formatter) => void;
readonly log: (data: string | Uint8Array | Formatter) => boolean;
readonly hr: () => void;
};

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

exports.Write = {
log: (data) => {
node_process_1.stdout.write(`${String(data)}\n`);
},
log: (data) => node_process_1.stdout.write(`${String(data)}\n`),
hr: () => {

@@ -11,0 +9,0 @@ const line = '─'.repeat(node_process_1.stdout.columns - 10 || 40);

{
"name": "poku",
"version": "2.5.0",
"version": "2.5.1-canary.b756605",
"description": "🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",

@@ -60,9 +60,9 @@ "main": "./lib/modules/index.js",

"@biomejs/biome": "1.8.3",
"@types/node": "^22.4.1",
"@types/node": "^22.5.3",
"c8": "^10.1.2",
"jsonc.min": "^1.0.0",
"jsonc.min": "^1.1.0",
"monocart-coverage-reports": "^2.10.3",
"packages-update": "^2.0.0",
"prettier": "^3.3.3",
"tsx": "4.17.0",
"tsx": "4.19.0",
"typescript": "^5.5.4"

@@ -69,0 +69,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