@contrast/dep-hooks
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -41,3 +41,3 @@ export = ExportHookDescriptor; | ||
*/ | ||
static create<T_1 extends Object>(descriptor: string | HookDescriptorOptions<T_1>): import("./export-hook-descriptor")<T_1>; | ||
static create<T_1 extends Object>(descriptor: string | HookDescriptorOptions<T_1>): ExportHookDescriptor<T_1>; | ||
/** | ||
@@ -44,0 +44,0 @@ * @param {HookDescriptorOptions<T>} options |
@@ -21,2 +21,3 @@ /* | ||
const { isBuiltin } = require('./helpers'); | ||
const { primordials: { StringPrototypeReplace } } = require('@contrast/common'); | ||
const DEFAULT_VERSION = '*'; | ||
@@ -52,5 +53,7 @@ /** @typedef {import('./package-finder').Metadata} Metadata */ | ||
/** @type {string} */ | ||
this.name = isBuiltin(name) ? name.replace(/^(node:)?/, 'node:') : name; | ||
// @ts-ignore | ||
this.name = isBuiltin(name) ? StringPrototypeReplace.call(name, /^(node:)?/, 'node:') : name; | ||
/** @type {string=} */ | ||
this.file = file?.replace(/\/?(index)?(\.js)?$/, ''); | ||
// @ts-ignore | ||
this.file = file ? StringPrototypeReplace.call(file, /\/?(index)?(\.js)?$/, '') : undefined; | ||
/** @type {string} */ | ||
@@ -57,0 +60,0 @@ this.shortname = this.file ? path.posix.join(this.name, this.file) : this.name; |
@@ -15,3 +15,2 @@ /* | ||
*/ | ||
// @ts-check | ||
'use strict'; | ||
@@ -21,2 +20,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path = require('node:path'); | ||
const { primordials: { StringPrototypeReplace, StringPrototypeSubstring, RegExpPrototypeTest } } = require('@contrast/common'); | ||
const pathSepRegex = new RegExp(`\\${path.sep}`, 'g'); | ||
@@ -33,13 +33,14 @@ /** | ||
function getShortname({ name, packageDir, file, main }) { | ||
const mainPath = path | ||
.join(packageDir, main ?? '') | ||
.replace(pathSepRegex, '\\$&'); | ||
const mainPath = StringPrototypeReplace.call(path.join(packageDir, main ?? ''), pathSepRegex, '\\$&'); | ||
const mainPathRegex = new RegExp(`^${mainPath}\\${path.sep}?(index)?(\\.js(on)?)?$`); | ||
const normalizedFilename = path.normalize(file); | ||
return mainPathRegex.test(normalizedFilename) | ||
? name | ||
: normalizedFilename | ||
.replace(path.normalize(packageDir), name) | ||
.replace(pathSepRegex, '/') | ||
.replace(/\/?(index)?\.js$/, ''); | ||
let normalizedFilename = path.normalize(file); | ||
if (RegExpPrototypeTest.call(mainPathRegex, normalizedFilename)) { | ||
return name; | ||
} | ||
else { | ||
normalizedFilename = StringPrototypeReplace.call(normalizedFilename, path.normalize(packageDir), name); | ||
normalizedFilename = StringPrototypeReplace.call(normalizedFilename, pathSepRegex, '/'); | ||
normalizedFilename = StringPrototypeReplace.call(normalizedFilename, /\/?(index)?\.js$/, ''); | ||
return normalizedFilename; | ||
} | ||
} | ||
@@ -54,3 +55,3 @@ /** | ||
if (name.startsWith('node:')) { | ||
name = name.substring(5); | ||
name = StringPrototypeSubstring.call(name, 5); | ||
} | ||
@@ -57,0 +58,0 @@ // @ts-expect-error we've set the node version to 14 before this was added. |
@@ -15,3 +15,3 @@ /* | ||
*/ | ||
// @ts-check | ||
// @ts-nocheck | ||
'use strict'; | ||
@@ -23,2 +23,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const { isBuiltin } = require('./helpers'); | ||
const { primordials: { StringPrototypeReplace, StringPrototypeSubstring, JSONParse } } = require('@contrast/common'); | ||
/** | ||
@@ -43,6 +44,6 @@ * @typedef {Object} Metadata | ||
if (isBuiltin(filename)) { | ||
filename = filename.replace(/^(node:)?/, 'node:'); | ||
filename = StringPrototypeReplace.call(filename, /^(node:)?/, 'node:'); | ||
return { | ||
name: filename, | ||
version: process.version.substring(1), | ||
version: StringPrototypeSubstring.call(process.version, 1), | ||
packageDir: filename, | ||
@@ -60,3 +61,3 @@ file: filename, | ||
const json = fs.readFileSync(pdj, 'utf8'); | ||
const { name, version, main } = JSON.parse(json); | ||
const { name, version, main } = JSONParse(json); | ||
return { | ||
@@ -63,0 +64,0 @@ name, |
{ | ||
"name": "@contrast/dep-hooks", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Post hooks for Module.prototype.require", | ||
@@ -21,6 +21,7 @@ "license": "SEE LICENSE IN LICENSE", | ||
"dependencies": { | ||
"@contrast/common": "1.26.0", | ||
"@contrast/find-package-json": "^1.1.0", | ||
"@contrast/logger": "1.10.0", | ||
"@contrast/logger": "1.11.0", | ||
"semver": "^7.6.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
111378
996
0
4
+ Added@contrast/common@1.26.0
+ Added@contrast/common@1.26.0(transitive)
+ Added@contrast/config@1.34.0(transitive)
+ Added@contrast/logger@1.11.0(transitive)
- Removed@contrast/common@1.25.0(transitive)
- Removed@contrast/config@1.33.0(transitive)
- Removed@contrast/logger@1.10.0(transitive)
Updated@contrast/logger@1.11.0