Comparing version 0.4.1 to 0.5.0-next.0
24
bin.js
#!/usr/bin/env node | ||
const sade = require('sade'); | ||
const parse = require('./parse'); | ||
const pkg = require('./package'); | ||
const { parse } = require('./parse'); | ||
const dimport = x => new Function(`return import(${ JSON.stringify(x) })`).call(0); | ||
const hasImport = (() => { | ||
try { new Function('import').call(0) } | ||
catch (err) { return !/unexpected/i.test(err.message) } | ||
})(); | ||
sade('uvu [dir] [pattern]') | ||
@@ -17,13 +24,8 @@ .version(pkg.version) | ||
let { suites } = await parse(dir, pattern, opts); | ||
let { exec, QUEUE } = require('.'); | ||
// TODO: mjs vs js file | ||
globalThis.UVU_DEFER = 1; | ||
suites.forEach((x, idx) => { | ||
globalThis.UVU_INDEX = idx; | ||
QUEUE.push([x.name]); | ||
require(x.file); // auto-add to queue | ||
}); | ||
await exec(opts.bail); | ||
if (hasImport) { | ||
await dimport('uvu/run').then(m => m.run(suites, opts)); | ||
} else { | ||
await require('uvu/run').run(suites, opts); | ||
} | ||
} catch (err) { | ||
@@ -30,0 +32,0 @@ console.error(err.stack || err.message); |
{ | ||
"name": "uvu", | ||
"version": "0.4.1", | ||
"version": "0.5.0-next.0", | ||
"repository": "lukeed/uvu", | ||
@@ -29,2 +29,6 @@ "description": "uvu is an extremely fast and lightweight test runner for Node.js and the browser", | ||
"import": "./parse/index.mjs" | ||
}, | ||
"./run": { | ||
"require": "./run/index.js", | ||
"import": "./run/index.mjs" | ||
} | ||
@@ -38,3 +42,4 @@ }, | ||
"diff", | ||
"dist" | ||
"dist", | ||
"run" | ||
], | ||
@@ -63,3 +68,3 @@ "modes": { | ||
"dequal": "^2.0.0", | ||
"diff": "^4.0.2", | ||
"diff": "^5.0.0", | ||
"kleur": "^4.0.3", | ||
@@ -66,0 +71,0 @@ "sade": "^1.7.3", |
type Arrayable<T> = T[] | T; | ||
interface Suite { | ||
export interface Suite { | ||
/** The relative file path */ | ||
@@ -10,3 +10,3 @@ name: string; | ||
interface Options { | ||
export interface Options { | ||
cwd: string; | ||
@@ -17,3 +17,3 @@ require: Arrayable<string>; | ||
interface Argv { | ||
export interface Argv { | ||
dir: string; | ||
@@ -24,4 +24,2 @@ suites: Suite[]; | ||
// TODO: named `parse` export | ||
// TODO: export type interfaces | ||
function parse(dir: string, pattern: string, opts?: Partial<Options>): Promise<Argv>; | ||
export = parse; | ||
export function parse(dir: string, pattern: string, opts?: Partial<Options>): Promise<Argv>; |
@@ -7,10 +7,7 @@ const { resolve } = require('path'); | ||
function exists(dep) { | ||
try { | ||
return require.resolve(dep); | ||
} catch (err) { | ||
return false; | ||
} | ||
try { return require.resolve(dep) } | ||
catch (err) { return false } | ||
} | ||
module.exports = async function (dir, pattern, opts = {}) { | ||
async function parse(dir, pattern, opts = {}) { | ||
if (pattern) pattern = toRegex(pattern); | ||
@@ -41,1 +38,3 @@ else if (dir) pattern = /(((?:[^\/]*(?:\/|$))*)[\\\/])?\w+\.([mc]js|[jt]sx?)$/; | ||
} | ||
exports.parse = parse; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
45577
19
1081
2
+ Addeddiff@5.2.0(transitive)
- Removeddiff@4.0.2(transitive)
Updateddiff@^5.0.0