New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

poku

Package Overview
Dependencies
Maintainers
0
Versions
90
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.3.0 to 2.4.0

lib/bin/watch.js

132

lib/bin/index.js
#! /usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_process_1 = __importDefault(require("process"));
const list_files_js_1 = require("../modules/helpers/list-files.js");

@@ -15,10 +11,12 @@ const get_arg_js_1 = require("../parsers/get-arg.js");

const env_js_1 = require("../modules/helpers/env.js");
const map_tests_js_1 = require("../services/map-tests.js");
const watch_js_1 = require("../services/watch.js");
const poku_js_1 = require("../modules/essentials/poku.js");
const write_js_1 = require("../services/write.js");
const options_js_1 = require("../parsers/options.js");
const cpus_js_1 = require("../polyfills/cpus.js");
(async () => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
if ((0, get_arg_js_1.hasArg)('version') || (0, get_arg_js_1.hasArg)('v', '-')) {
const { VERSION } = require('../configs/poku.js');
write_js_1.Write.log(VERSION);
return;
}
const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');

@@ -66,2 +64,23 @@ const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);

}
if ((0, get_arg_js_1.hasArg)('list-files')) {
const { listFiles } = require('../modules/helpers/list-files.js');
let total = 0;
write_js_1.Write.hr();
for (const dir of dirs) {
const files = await listFiles(dir, {
filter: typeof filter === 'string'
? new RegExp((0, list_files_js_1.escapeRegExp)(filter))
: filter,
exclude: typeof exclude === 'string'
? new RegExp((0, list_files_js_1.escapeRegExp)(exclude))
: exclude,
});
total += files.length;
write_js_1.Write.log(files.map((file) => `${(0, format_js_1.format)('-').dim()} ${file}`).join('\n'));
}
write_js_1.Write.hr();
write_js_1.Write.log(`Total test files: ${(0, format_js_1.format)(String(total)).bold()}`);
write_js_1.Write.hr();
return;
}
const tasks = [];

@@ -131,95 +150,8 @@

}
const watchers = new Set();
const executing = new Set();
const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
let isRunning = false;
const listenStdin = (input) => {
if (isRunning || executing.size > 0) {
return;
}
if (String(input).trim() === 'rs') {
for (const watcher of watchers) {
watcher.stop();
}
watchers.clear();
resultsClear();
startTests();
}
};
const resultsClear = () => {
files_js_1.fileResults.success.clear();
files_js_1.fileResults.fail.clear();
};
const startTests = () => {
if (isRunning || executing.size > 0) {
return;
}
isRunning = true;
Promise.all(tasks).then(() => {
(0, poku_js_1.poku)(dirs, options)
.then(() => {
if (watchMode) {
node_process_1.default.stdin.removeListener('data', listenStdin);
node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
resultsClear();
(0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude).then((mappedTests) => {
for (const mappedTest of Array.from(mappedTests.keys())) {
const currentWatcher = (0, watch_js_1.watch)(mappedTest, (file, event) => {
if (event === 'change') {
const filePath = (0, map_tests_js_1.normalizePath)(file);
if (executing.has(filePath)) {
return;
}
executing.add(filePath);
resultsClear();
const tests = mappedTests.get(filePath);
if (!tests) {
return;
}
(0, poku_js_1.poku)(Array.from(tests), {
...options,
concurrency: concurrency !== null && concurrency !== void 0 ? concurrency : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1),
}).then(() => {
setTimeout(() => {
executing.delete(filePath);
}, interval);
});
}
});
currentWatcher.then((watcher) => watchers.add(watcher));
}
});
for (const dir of dirs) {
const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
if (event === 'change') {
if (executing.has(file)) {
return;
}
executing.add(file);
resultsClear();
(0, poku_js_1.poku)(file, options).then(() => {
setTimeout(() => {
executing.delete(file);
}, interval);
});
}
});
currentWatcher.then((watcher) => watchers.add(watcher));
}
write_js_1.Write.hr();
write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
node_process_1.default.stdin.setEncoding('utf-8');
node_process_1.default.stdin.on('data', listenStdin);
}
})
.finally(() => {
isRunning = false;
});
});
};
startTests();
await Promise.all(tasks);
await (0, poku_js_1.poku)(dirs, options);
if (watchMode) {
const { startWatch } = require('./watch.js');
await startWatch(dirs, options);
}
})();

@@ -7,1 +7,2 @@ export declare const results: {

};
export declare const VERSION = "";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.results = void 0;
exports.VERSION = exports.results = void 0;
exports.results = {

@@ -10,1 +10,2 @@ success: 0,

};
exports.VERSION = '2.4.0';
/** By default **Poku** only shows outputs generated from itself. This helper allows you to use an alternative to `console.log` with **Poku**. */
export declare const log: (message: string) => void;
export declare const log: (...args: unknown[]) => void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = void 0;
const assert_js_1 = require("../../parsers/assert.js");
const write_js_1 = require("../../services/write.js");
/** By default **Poku** only shows outputs generated from itself. This helper allows you to use an alternative to `console.log` with **Poku**. */
const log = (message) => write_js_1.Write.log(`\x1b[0m${message}\x1b[0m`);
const log = (...args) => {
const parsedMessages = args
.map((arg) => (0, assert_js_1.parseResultType)(arg))
.join(' ')
.split('\n')
.map((line) => `\x1b[0m${line}\x1b[0m`)
.join('\n');
write_js_1.Write.log(parsedMessages);
};
exports.log = log;

@@ -19,2 +19,3 @@ import type { ConfigFile } from '../@types/poku.js';

export { listFiles } from './helpers/list-files.js';
export { VERSION as version } from '../configs/poku.js';
export type { Code } from '../@types/code.js';

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineConfig = 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;
exports.defineConfig = exports.version = 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");

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

Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return list_files_js_1.listFiles; } });
var poku_js_2 = require("../configs/poku.js");
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return poku_js_2.VERSION; } });
/** 🐷 Auxiliary function to define the `poku` configurations */
const defineConfig = (options) => options;
exports.defineConfig = defineConfig;
{
"name": "poku",
"version": "2.3.0",
"version": "2.4.0",
"description": "🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",

@@ -54,3 +54,3 @@ "main": "./lib/modules/index.js",

"build": "tsc && tsc -p tsconfig.test.json",
"postbuild": "tsx tools/compatibility/node.ts && tsx tools/compatibility/comments.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && rm -f ./lib/@types/*.js ./lib/bin/*.ts && npm run build:deno && chmod +x lib/bin/index.js",
"postbuild": "tsx tools/compatibility/node.ts && tsx tools/compatibility/comments.ts && tsx tools/build/version.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && rm -f ./lib/@types/*.js ./lib/bin/*.ts && npm run build:deno && chmod +x lib/bin/index.js",
"build:deno": "tsc -p tsconfig.mjs.json",

@@ -66,3 +66,3 @@ "postbuild:deno": "tsx tools/build/check-deno-polyfill.ts",

"@biomejs/biome": "1.8.3",
"@types/node": "^22.0.0",
"@types/node": "^22.0.2",
"c8": "^10.1.2",

@@ -73,3 +73,3 @@ "jsonc.min": "^1.0.0",

"prettier": "^3.3.3",
"tsx": "4.16.3",
"tsx": "4.16.5",
"typescript": "^5.5.4"

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