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

@ms-cloudpack/path-utilities

Package Overview
Dependencies
Maintainers
3
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ms-cloudpack/path-utilities - npm Package Compare versions

Comparing version 2.8.4 to 3.0.0

8

lib/resolve.d.ts
/**
* Resolves a package path given the parent path.
* Resolves a package name given the parent path. This uses the `resolve` package (which does not
* respect exports maps) to resolve `${packageName}/package.json`.
*
* (To resolve a path respecting exports maps, use `resolveModule` instead.)
*
* @param packageName - The package name.
* @param parentPath - The parent path.
* @returns The resolved absolute package path.
* @returns The resolved absolute path to the package root, or undefined if it couldn't be resolved.
*/
export declare function resolve(packageName: string, parentPath: string): Promise<string | undefined>;
//# sourceMappingURL=resolve.d.ts.map
import path from 'path';
import resolvePackage from 'resolve';
/**
* Resolves a package path given the parent path.
* Resolves a package name given the parent path. This uses the `resolve` package (which does not
* respect exports maps) to resolve `${packageName}/package.json`.
*
* (To resolve a path respecting exports maps, use `resolveModule` instead.)
*
* @param packageName - The package name.
* @param parentPath - The parent path.
* @returns The resolved absolute package path.
* @returns The resolved absolute path to the package root, or undefined if it couldn't be resolved.
*/
export async function resolve(packageName, parentPath) {
const packageRootImport = path.join(packageName, 'package.json');
return new Promise((success) => {
return new Promise((promiseResolve) => {
try {
resolvePackage(packageRootImport, { basedir: parentPath, preserveSymlinks: false }, (err, resolvedPath) => {
if (err || !resolvedPath) {
success(undefined);
promiseResolve(undefined);
}
else {
success(path.dirname(resolvedPath));
promiseResolve(path.dirname(resolvedPath));
}

@@ -23,3 +27,3 @@ });

catch (e) {
success(undefined);
promiseResolve(undefined);
}

@@ -26,0 +30,0 @@ });

@@ -0,9 +1,32 @@

interface ResolveModuleCommonParams {
/** Specifier to resolve */
importSpecifier: string;
/** If true, keep symlinks instead of resolving them */
preserveSymlinks?: boolean;
}
/**
* Resolve a module specifier to a file url (with protocol ie: file:). Throws if it can't be resolved.
* @returns - The resolved file url as a string.
* Resolve a module specifier to a file URL using `import-meta-resolve` (which respects exports maps).
* Throws if it can't be resolved.
* (The parent to start resolution from can be specified as either a file path or URL.)
*
* WARNING: As of writing, this only uses Node-appropriate export conditions, and so is only
* intended to be used for resolving things such as config files and webpack loaders.
*
* @returns The resolved file URL.
*/
export declare function resolveModule(params: {
importSpecifier: string;
export declare function resolveModule(params: ResolveModuleCommonParams & {
/**
* Parent file path **(not URL)** to start resolving from.
* (Use `parentUrl` for a file URL.)
*/
parentPath: string;
}): URL;
export declare function resolveModule(params: ResolveModuleCommonParams & {
/**
* Parent URL to start resolving from, such as `import.meta.url` of the calling file.
* (Use `parentPath` for a file path.)
*/
parentUrl: string;
}): string;
}): URL;
export {};
//# sourceMappingURL=resolveModule.d.ts.map

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

import { makeUrl } from '@ms-cloudpack/path-string-parsing';
import { moduleResolve } from 'import-meta-resolve';

@@ -6,11 +7,8 @@ import { pathToFileURL } from 'url';

const conditions = new Set(['import', 'require', 'node']);
/**
* Resolve a module specifier to a file url (with protocol ie: file:). Throws if it can't be resolved.
* @returns - The resolved file url as a string.
*/
export function resolveModule(params) {
const { importSpecifier, parentUrl } = params;
const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(parentUrl), conditions);
return resolvedUrl.toString();
const { importSpecifier, preserveSymlinks } = params;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- types verify one or the other is set
const parentUrl = params.parentPath ? pathToFileURL(params.parentPath) : makeUrl(params.parentUrl);
return moduleResolve(importSpecifier, parentUrl, conditions, preserveSymlinks);
}
//# sourceMappingURL=resolveModule.js.map
{
"name": "@ms-cloudpack/path-utilities",
"version": "2.8.4",
"version": "3.0.0",
"description": "Path utilities for Cloudpack.",

@@ -5,0 +5,0 @@ "license": "MIT",

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

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