Socket
Socket
Sign inDemoInstall

@pnpm/local-resolver

Package Overview
Dependencies
Maintainers
3
Versions
128
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 1.0.5 to 2.0.0

2

lib/index.d.ts

@@ -10,3 +10,3 @@ import { ResolveResult } from '@pnpm/resolver-base';

prefix: string;
shrinkwrapDirectory?: string;
lockfileDirectory?: string;
}): Promise<(ResolveResult & {

@@ -13,0 +13,0 @@ id: string;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,57 +11,53 @@ const read_package_json_1 = require("@pnpm/read-package-json");

*/
function resolveLocal(wantedDependency, opts) {
return __awaiter(this, void 0, void 0, function* () {
const spec = parsePref_1.default(wantedDependency.pref, opts.prefix, opts.shrinkwrapDirectory || opts.prefix);
if (!spec)
return null;
if (spec.type === 'file') {
return {
id: spec.id,
normalizedPref: spec.normalizedPref,
resolution: {
integrity: yield getFileIntegrity(spec.fetchSpec),
tarball: spec.id,
},
resolvedVia: 'local-filesystem',
};
}
let localPkg;
try {
localPkg = yield read_package_json_1.default(path.join(spec.fetchSpec, 'package.json'));
}
catch (internalErr) {
switch (internalErr.code) {
case 'ENOTDIR': {
const err = new Error(`Could not install from "${spec.fetchSpec}" as it is not a directory.`);
err['code'] = 'ERR_PNPM_NOT_PACKAGE_DIRECTORY'; // tslint:disable-line:no-string-literal
throw err;
}
case 'ENOENT': {
const err = new Error(`Could not install from "${spec.fetchSpec}" as it does not contain a package.json file.`);
err['code'] = 'ERR_PNPM_DIRECTORY_HAS_NO_PACKAGE_JSON'; // tslint:disable-line:no-string-literal
throw err;
}
default: {
throw internalErr;
}
}
}
async function resolveLocal(wantedDependency, opts) {
const spec = parsePref_1.default(wantedDependency.pref, opts.prefix, opts.lockfileDirectory || opts.prefix);
if (!spec)
return null;
if (spec.type === 'file') {
return {
id: spec.id,
normalizedPref: spec.normalizedPref,
package: localPkg,
resolution: {
directory: spec.dependencyPath,
type: 'directory',
integrity: await getFileIntegrity(spec.fetchSpec),
tarball: spec.id,
},
resolvedVia: 'local-filesystem',
};
});
}
let localPkg;
try {
localPkg = await read_package_json_1.default(path.join(spec.fetchSpec, 'package.json'));
}
catch (internalErr) {
switch (internalErr.code) {
case 'ENOTDIR': {
const err = new Error(`Could not install from "${spec.fetchSpec}" as it is not a directory.`);
err['code'] = 'ERR_PNPM_NOT_PACKAGE_DIRECTORY'; // tslint:disable-line:no-string-literal
throw err;
}
case 'ENOENT': {
const err = new Error(`Could not install from "${spec.fetchSpec}" as it does not contain a package.json file.`);
err['code'] = 'ERR_PNPM_DIRECTORY_HAS_NO_PACKAGE_JSON'; // tslint:disable-line:no-string-literal
throw err;
}
default: {
throw internalErr;
}
}
}
return {
id: spec.id,
normalizedPref: spec.normalizedPref,
package: localPkg,
resolution: {
directory: spec.dependencyPath,
type: 'directory',
},
resolvedVia: 'local-filesystem',
};
}
exports.default = resolveLocal;
function getFileIntegrity(filename) {
return __awaiter(this, void 0, void 0, function* () {
return (yield ssri.fromStream(fs.createReadStream(filename))).toString();
});
async function getFileIntegrity(filename) {
return (await ssri.fromStream(fs.createReadStream(filename))).toString();
}
//# sourceMappingURL=index.js.map

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

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

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

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

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

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

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

exports.default = parsePref;
function fromLocal(pref, importerPrefix, shrinkwrapDirectory, type) {
function fromLocal(pref, importerPrefix, lockfileDirectory, type) {
if (!importerPrefix)

@@ -64,5 +64,5 @@ importerPrefix = process.cwd();

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

@@ -69,0 +69,0 @@ dependencyPath,

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

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

"engines": {
"node": ">=6"
"node": ">=8"
},

@@ -17,3 +17,3 @@ "scripts": {

"tsc": "tsc",
"test": "npm run lint && preview && ts-node test --ts-node",
"test": "npm run tsc && npm run lint && ts-node test --ts-node",
"md": "mos",

@@ -23,6 +23,3 @@ "prepublishOnly": "npm run tsc",

},
"repository": {
"type": "git",
"url": "git+https://github.com/pnpm/local-resolver.git"
},
"repository": "https://github.com/pnpm/pnpm/blob/master/packages/local-resolver",
"keywords": [

@@ -36,11 +33,11 @@ "pnpm",

"bugs": {
"url": "https://github.com/pnpm/local-resolver/issues"
"url": "https://github.com/pnpm/pnpm/issues"
},
"homepage": "https://github.com/pnpm/local-resolver#readme",
"homepage": "https://github.com/pnpm/pnpm/blob/master/packages/local-resolver#readme",
"dependencies": {
"@pnpm/read-package-json": "1.1.1",
"@pnpm/resolver-base": "^2.1.0",
"@pnpm/types": "^2.0.0",
"@types/graceful-fs": "^4.1.2",
"@types/node": "^10.0.6",
"@pnpm/read-package-json": "2.0.0",
"@pnpm/resolver-base": "3.0.0",
"@pnpm/types": "3.0.0",
"@types/graceful-fs": "4.1.3",
"@types/node": "10.12.30",
"graceful-fs": "4.1.15",

@@ -51,8 +48,9 @@ "normalize-path": "3.0.0",

"devDependencies": {
"@pnpm/local-resolver": "link:",
"@pnpm/tslint-config": "0.0.0",
"@types/tape": "^4.2.31",
"mos": "^2.0.0-alpha.3",
"mos-plugin-readme": "^1.0.4",
"package-preview": "^2.0.0",
"tape": "^4.8.0",
"ts-node": "^7.0.0",
"ts-node": "8.0.3",
"tslint": "^5.8.0",

@@ -59,0 +57,0 @@ "typescript": "^3.0.0"

@@ -5,4 +5,4 @@ # @pnpm/local-resolver

<!--@shields('npm', 'travis')-->
[![npm version](https://img.shields.io/npm/v/@pnpm/local-resolver.svg)](https://www.npmjs.com/package/@pnpm/local-resolver) [![Build Status](https://img.shields.io/travis/pnpm/local-resolver/master.svg)](https://travis-ci.org/pnpm/local-resolver)
<!--@shields('npm')-->
[![npm version](https://img.shields.io/npm/v/@pnpm/local-resolver.svg)](https://www.npmjs.com/package/@pnpm/local-resolver)
<!--/@-->

@@ -9,0 +9,0 @@

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