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

@pnpm/local-resolver

Package Overview
Dependencies
Maintainers
3
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/local-resolver - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

16

lib/index.d.ts
import { DirectoryResolution, ResolveResult, TarballResolution } from '@pnpm/resolver-base';
import { DependencyManifest } from '@pnpm/types';
/**

@@ -9,13 +8,8 @@ * Resolves a package hosted on the local filesystem

}, opts: {
prefix: string;
lockfileDirectory?: string;
}): Promise<(ResolveResult & ({
id: string;
normalizedPref: string;
importerDir: string;
lockfileDir?: string;
}): Promise<(ResolveResult & Required<Pick<ResolveResult, 'normalizedPref'>> & ({
resolution: TarballResolution;
} | {
id: string;
normalizedPref: string;
package: DependencyManifest;
} | ({
resolution: DirectoryResolution;
})) | null>;
} & Required<Pick<ResolveResult, 'manifest'>>))) | null>;

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

async function resolveLocal(wantedDependency, opts) {
const spec = parsePref_1.default(wantedDependency.pref, opts.prefix, opts.lockfileDirectory || opts.prefix);
const spec = parsePref_1.default(wantedDependency.pref, opts.importerDir, opts.lockfileDir || opts.importerDir);
if (!spec)

@@ -46,4 +46,4 @@ return null;

id: spec.id,
manifest: localDependencyManifest,
normalizedPref: spec.normalizedPref,
package: localDependencyManifest,
resolution: {

@@ -50,0 +50,0 @@ directory: spec.dependencyPath,

@@ -8,2 +8,2 @@ export interface LocalPackageSpec {

}
export default function parsePref(pref: string, importerPrefix: string, lockfileDirectory: string): LocalPackageSpec | null;
export default function parsePref(pref: string, importerDir: string, lockfileDir: string): LocalPackageSpec | null;

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

const isAbsolutePath = /^[/]|^[A-Za-z]:/;
function parsePref(pref, importerPrefix, lockfileDirectory) {
function parsePref(pref, importerDir, lockfileDir) {
if (pref.startsWith('link:')) {
return fromLocal(pref, importerPrefix, lockfileDirectory, 'directory');
return fromLocal(pref, importerDir, lockfileDir, 'directory');
}

@@ -24,3 +24,3 @@ if (pref.endsWith('.tgz')

const type = isFilename.test(pref) ? 'file' : 'directory';
return fromLocal(pref, importerPrefix, lockfileDirectory, type);
return fromLocal(pref, importerDir, lockfileDir, type);
}

@@ -39,5 +39,3 @@ if (pref.startsWith('path:')) {

exports.default = parsePref;
function fromLocal(pref, importerPrefix, lockfileDirectory, type) {
if (!importerPrefix)
importerPrefix = process.cwd();
function fromLocal(pref, importerDir, lockfileDir, type) {
const spec = pref.replace(/\\/g, '/')

@@ -55,3 +53,3 @@ .replace(/^(file|link):[/]*([A-Za-z]:)/, '$2') // drive name paths on windows

else {
fetchSpec = resolvePath(importerPrefix, spec);
fetchSpec = resolvePath(importerDir, spec);
if (isAbsolute(spec)) {

@@ -61,9 +59,9 @@ normalizedPref = `${protocol}${spec}`;

else {
normalizedPref = `${protocol}${path.relative(importerPrefix, fetchSpec)}`;
normalizedPref = `${protocol}${path.relative(importerDir, fetchSpec)}`;
}
}
const dependencyPath = normalize(path.relative(importerPrefix, fetchSpec));
const id = type === 'directory' || importerPrefix === lockfileDirectory
const dependencyPath = normalize(path.relative(importerDir, fetchSpec));
const id = type === 'directory' || importerDir === lockfileDir
? `${protocol}${dependencyPath}`
: `${protocol}${normalize(path.relative(lockfileDirectory, fetchSpec))}`;
: `${protocol}${normalize(path.relative(lockfileDir, fetchSpec))}`;
return {

@@ -70,0 +68,0 @@ dependencyPath,

{
"name": "@pnpm/local-resolver",
"version": "3.0.0",
"version": "4.0.0",
"description": "Resolver for local packages",

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

"@pnpm/read-importer-manifest": "2.0.0",
"@pnpm/resolver-base": "4.0.0",
"@pnpm/resolver-base": "5.0.0",
"@pnpm/types": "4.0.0",

@@ -38,0 +38,0 @@ "graceful-fs": "4.2.1",

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