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

@pnpm/link-bins

Package Overview
Dependencies
Maintainers
2
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/link-bins - npm Package Compare versions

Comparing version 6.0.8 to 6.1.0

5

lib/index.d.ts

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

import { DependencyManifest } from '@pnpm/types';
import { DependencyManifest, ProjectManifest } from '@pnpm/types';
export declare type WarningCode = 'BINARIES_CONFLICT' | 'EMPTY_BIN';

@@ -6,2 +6,4 @@ export declare type WarnFunction = (msg: string, code: WarningCode) => void;

allowExoticManifests?: boolean;
nodeExecPathByAlias?: Record<string, string>;
projectManifest?: ProjectManifest;
warn: WarnFunction;

@@ -12,2 +14,3 @@ }) => Promise<string[]>;

manifest: DependencyManifest;
nodeExecPath?: string;
location: string;

@@ -14,0 +17,0 @@ }>, binsTarget: string, opts: {

43

lib/index.js

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

const error_1 = __importDefault(require("@pnpm/error"));
const manifest_utils_1 = require("@pnpm/manifest-utils");
const package_bins_1 = __importDefault(require("@pnpm/package-bins"));

@@ -38,10 +39,32 @@ const read_modules_dir_1 = __importDefault(require("@pnpm/read-modules-dir"));

};
const directDependencies = opts.projectManifest == null
? undefined
: new Set(Object.keys(manifest_utils_1.getAllDependenciesFromManifest(opts.projectManifest)));
const allCmds = unnest_1.default((await Promise.all(allDeps
.map((depName) => path_1.default.resolve(modulesDir, depName))
.filter((depDir) => !is_subdir_1.default(depDir, binsDir)) // Don't link own bins
.map((depDir) => normalize_path_1.default(depDir))
.map(getPackageBins.bind(null, pkgBinOpts))))
.map((alias) => {
var _a;
return ({
depDir: path_1.default.resolve(modulesDir, alias),
isDirectDependency: directDependencies === null || directDependencies === void 0 ? void 0 : directDependencies.has(alias),
nodeExecPath: (_a = opts.nodeExecPathByAlias) === null || _a === void 0 ? void 0 : _a[alias],
});
})
.filter(({ depDir }) => !is_subdir_1.default(depDir, binsDir)) // Don't link own bins
.map(async ({ depDir, isDirectDependency, nodeExecPath }) => {
const target = normalize_path_1.default(depDir);
const cmds = await getPackageBins(pkgBinOpts, target, nodeExecPath);
return cmds.map((cmd) => ({ ...cmd, isDirectDependency }));
})))
.filter((cmds) => cmds.length));
return linkBins(allCmds, binsDir, opts);
const cmdsToLink = directDependencies != null ? preferDirectCmds(allCmds) : allCmds;
return linkBins(cmdsToLink, binsDir, opts);
};
function preferDirectCmds(allCmds) {
const [directCmds, hoistedCmds] = partition_1.default((cmd) => cmd.isDirectDependency === true, allCmds);
const usedDirectCmds = new Set(directCmds.map((directCmd) => directCmd.name));
return [
...directCmds,
...hoistedCmds.filter(({ name }) => !usedDirectCmds.has(name)),
];
}
async function linkBinsOfPackages(pkgs, binsTarget, opts) {

@@ -51,3 +74,3 @@ if (pkgs.length === 0)

const allCmds = unnest_1.default((await Promise.all(pkgs
.map(async (pkg) => getPackageBinsFromManifest(pkg.manifest, pkg.location))))
.map(async (pkg) => getPackageBinsFromManifest(pkg.manifest, pkg.location, pkg.nodeExecPath))))
.filter((cmds) => cmds.length));

@@ -84,3 +107,3 @@ return linkBins(allCmds, binsTarget, opts);

}
async function getPackageBins(opts, target) {
async function getPackageBins(opts, target, nodeExecPath) {
const manifest = opts.allowExoticManifests

@@ -100,5 +123,5 @@ ? await read_project_manifest_1.safeReadProjectManifestOnly(target)

}
return getPackageBinsFromManifest(manifest, target);
return getPackageBinsFromManifest(manifest, target, nodeExecPath);
}
async function getPackageBinsFromManifest(manifest, pkgDir) {
async function getPackageBinsFromManifest(manifest, pkgDir, nodeExecPath) {
const cmds = await package_bins_1.default(manifest, pkgDir);

@@ -110,2 +133,3 @@ return cmds.map((cmd) => ({

makePowerShellShim: POWER_SHELL_IS_SUPPORTED && manifest.name !== 'pnpm',
nodeExecPath,
}));

@@ -126,2 +150,3 @@ }

nodePath,
nodeExecPath: cmd.nodeExecPath,
});

@@ -128,0 +153,0 @@ }

{
"name": "@pnpm/link-bins",
"version": "6.0.8",
"version": "6.1.0",
"description": "Link bins to node_modules/.bin",

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

"@pnpm/error": "2.0.0",
"@pnpm/manifest-utils": "2.1.0",
"@pnpm/package-bins": "5.0.5",

@@ -32,3 +33,3 @@ "@pnpm/read-modules-dir": "3.0.1",

"@pnpm/types": "7.4.0",
"@zkochan/cmd-shim": "^5.1.3",
"@zkochan/cmd-shim": "^5.2.0",
"is-subdir": "^1.1.1",

@@ -35,0 +36,0 @@ "is-windows": "^1.0.2",

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