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

@pnpm/local-resolver

Package Overview
Dependencies
Maintainers
2
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 0.1.2 to 0.2.0

11

lib/index.js

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

const fs = require("graceful-fs");
const normalize = require("normalize-path");
const path = require("path");

@@ -28,11 +27,9 @@ const readPackageJsonCB = require("read-package-json");

return null;
const dependencyPath = normalize(path.relative(opts.prefix, spec.fetchSpec));
const id = `file:${dependencyPath}`;
if (spec.type === 'file') {
return {
id,
id: spec.id,
normalizedPref: spec.normalizedPref,
resolution: {
integrity: yield getFileIntegrity(spec.fetchSpec),
tarball: id,
tarball: spec.id,
},

@@ -43,7 +40,7 @@ };

return {
id,
id: spec.id,
normalizedPref: spec.normalizedPref,
package: localPkg,
resolution: {
directory: dependencyPath,
directory: spec.dependencyPath,
type: 'directory',

@@ -50,0 +47,0 @@ },

export interface LocalPackageSpec {
dependencyPath: string;
fetchSpec: string;
id: string;
type: 'directory' | 'file';

@@ -4,0 +6,0 @@ normalizedPref: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const normalize = require("normalize-path");
const osenv = require("osenv");

@@ -11,2 +12,5 @@ const path = require("path");

function parsePref(pref, where) {
if (pref.startsWith('link:')) {
return fromLocal(pref, where, 'directory');
}
if (pref.endsWith('.tgz')

@@ -18,33 +22,48 @@ || pref.endsWith('.tar.gz')

|| isFilespec.test(pref)) {
return fromFile(pref, where);
const type = isFilename.test(pref) ? 'file' : 'directory';
return fromLocal(pref, where, type);
}
if (pref.startsWith('path:')) {
const err = new Error('Local dependencies via `path:` prefix are not supported. ' +
'Use the `link:` prefix for folder dependencies and `file:` for local tarballs');
// tslint:disable:no-string-literal
err['code'] = 'INVALID_PREF';
err['pref'] = pref;
// tslint:enable:no-string-literal
throw err;
}
return null;
}
exports.default = parsePref;
function fromFile(pref, where) {
function fromLocal(pref, where, type) {
if (!where)
where = process.cwd();
const type = isFilename.test(pref) ? 'file' : 'directory';
const spec = pref.replace(/\\/g, '/')
.replace(/^file:[/]*([A-Za-z]:)/, '$1') // drive name paths on windows
.replace(/^file:(?:[/]*([~./]))?/, '$1');
.replace(/^(file|link):[/]*([A-Za-z]:)/, '$2') // drive name paths on windows
.replace(/^(file|link):(?:[/]*([~./]))?/, '$2');
// TODO: always use link: for directory dependencies
const prefPrefix = pref.startsWith('link:') ? 'link:' : 'file:';
let fetchSpec;
let normalizedPref;
if (/^~[/]/.test(spec)) {
// this is needed for windows and for file:~/foo/bar
return {
fetchSpec: resolvePath(osenv.home(), spec.slice(2)),
normalizedPref: `file:${spec}`,
type,
};
fetchSpec = resolvePath(osenv.home(), spec.slice(2));
normalizedPref = `${prefPrefix}${spec}`;
}
const fetchSpec = resolvePath(where, spec);
if (isAbsolute(spec)) {
return {
fetchSpec,
normalizedPref: `file:${spec}`,
type,
};
else {
fetchSpec = resolvePath(where, spec);
if (isAbsolute(spec)) {
normalizedPref = `${prefPrefix}${spec}`;
}
else {
normalizedPref = `${prefPrefix}${path.relative(where, fetchSpec)}`;
}
}
const dependencyPath = normalize(path.relative(where, fetchSpec));
const id = `${prefPrefix}${dependencyPath}`;
return {
dependencyPath,
fetchSpec,
normalizedPref: `file:${path.relative(where, fetchSpec)}`,
id,
normalizedPref,
type,

@@ -51,0 +70,0 @@ };

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

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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