@pnpm/link-bins
Advanced tools
Comparing version 6.0.8 to 6.1.0
@@ -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: { |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
18266
179
0
13
+ Added@pnpm/manifest-utils@2.1.0
+ Added@pnpm/core-loggers@6.0.4(transitive)
+ Added@pnpm/logger@4.0.0(transitive)
+ Added@pnpm/manifest-utils@2.1.0(transitive)
+ Addedbole@4.0.1(transitive)
+ Addedfast-safe-stringify@2.1.1(transitive)
+ Addedindividual@3.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedndjson@2.0.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsplit2@3.2.2(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedthrough2@4.0.2(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
Updated@zkochan/cmd-shim@^5.2.0