Socket
Socket
Sign inDemoInstall

@pnpm/link-bins

Package Overview
Dependencies
Maintainers
3
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 5.3.25 to 6.0.0

17

CHANGELOG.md
# @pnpm/link-bins
## 6.0.0
### Major Changes
- 97b986fbc: Node.js 10 support is dropped. At least Node.js 12.17 is required for the package to work.
### Patch Changes
- 06c6c9959: Don't create a PowerShell command shim for pnpm commands.
- Updated dependencies [97b986fbc]
- @pnpm/error@2.0.0
- @pnpm/package-bins@5.0.0
- @pnpm/read-modules-dir@3.0.0
- @pnpm/read-package-json@5.0.0
- @pnpm/read-project-manifest@2.0.0
- @pnpm/types@7.0.0
## 5.3.25

@@ -4,0 +21,0 @@

88

lib/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -7,2 +26,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.linkBinsOfPackages = void 0;
const fs_1 = require("fs");
const module_1 = __importDefault(require("module"));
const path_1 = __importDefault(require("path"));
const error_1 = __importDefault(require("@pnpm/error"));

@@ -13,16 +35,13 @@ const package_bins_1 = __importDefault(require("@pnpm/package-bins"));

const read_project_manifest_1 = require("@pnpm/read-project-manifest");
const Module = require("module");
const cmdShim = require("@zkochan/cmd-shim");
const isSubdir = require("is-subdir");
const isWindows = require("is-windows");
const fs = require("mz/fs");
const normalizePath = require("normalize-path");
const pSettle = require("p-settle");
const path = require("path");
const R = require("ramda");
const IS_WINDOWS = isWindows();
const cmd_shim_1 = __importDefault(require("@zkochan/cmd-shim"));
const is_subdir_1 = __importDefault(require("is-subdir"));
const is_windows_1 = __importDefault(require("is-windows"));
const normalize_path_1 = __importDefault(require("normalize-path"));
const p_settle_1 = __importDefault(require("p-settle"));
const R = __importStar(require("ramda"));
const IS_WINDOWS = (0, is_windows_1.default)();
const EXECUTABLE_SHEBANG_SUPPORTED = !IS_WINDOWS;
const POWER_SHELL_IS_SUPPORTED = IS_WINDOWS;
exports.default = async (modulesDir, binsDir, opts) => {
const allDeps = await read_modules_dir_1.default(modulesDir);
const allDeps = await (0, read_modules_dir_1.default)(modulesDir);
// If the modules dir does not exist, do nothing

@@ -36,5 +55,5 @@ if (allDeps === null)

const allCmds = R.unnest((await Promise.all(allDeps
.map((depName) => path.resolve(modulesDir, depName))
.filter((depDir) => !isSubdir(depDir, binsDir)) // Don't link own bins
.map((depDir) => normalizePath(depDir))
.map((depName) => path_1.default.resolve(modulesDir, depName))
.filter((depDir) => !(0, is_subdir_1.default)(depDir, binsDir)) // Don't link own bins
.map((depDir) => (0, normalize_path_1.default)(depDir))
.map(getPackageBins.bind(null, pkgBinOpts))))

@@ -45,6 +64,6 @@ .filter((cmds) => cmds.length));

async function linkBinsOfPackages(pkgs, binsTarget, opts) {
if (!pkgs.length)
if (pkgs.length === 0)
return [];
const allCmds = R.unnest((await Promise.all(pkgs
.map((pkg) => getPackageBinsFromManifest(pkg.manifest, pkg.location))))
.map(async (pkg) => getPackageBinsFromManifest(pkg.manifest, pkg.location))))
.filter((cmds) => cmds.length));

@@ -55,9 +74,9 @@ return linkBins(allCmds, binsTarget, opts);

async function linkBins(allCmds, binsDir, opts) {
if (!allCmds.length)
if (allCmds.length === 0)
return [];
await fs.mkdir(binsDir, { recursive: true });
await fs_1.promises.mkdir(binsDir, { recursive: true });
const [cmdsWithOwnName, cmdsWithOtherNames] = R.partition(({ ownName }) => ownName, allCmds);
const results1 = await pSettle(cmdsWithOwnName.map((cmd) => linkBin(cmd, binsDir)));
const results1 = await (0, p_settle_1.default)(cmdsWithOwnName.map(async (cmd) => linkBin(cmd, binsDir)));
const usedNames = R.fromPairs(cmdsWithOwnName.map((cmd) => [cmd.name, cmd.name]));
const results2 = await pSettle(cmdsWithOtherNames.map((cmd) => {
const results2 = await (0, p_settle_1.default)(cmdsWithOtherNames.map(async (cmd) => {
if (usedNames[cmd.name]) {

@@ -79,9 +98,10 @@ opts.warn(`Cannot link binary '${cmd.name}' of '${cmd.pkgName}' to '${binsDir}': binary of '${usedNames[cmd.name]}' is already linked`, 'BINARIES_CONFLICT');

async function isFromModules(filename) {
const real = await fs.realpath(filename);
return normalizePath(real).includes('/node_modules/');
const real = await fs_1.promises.realpath(filename);
return (0, normalize_path_1.default)(real).includes('/node_modules/');
}
async function getPackageBins(opts, target) {
const manifest = opts.allowExoticManifests
? await read_project_manifest_1.safeReadProjectManifestOnly(target) : await safeReadPkgJson(target);
if (!manifest) {
? await (0, read_project_manifest_1.safeReadProjectManifestOnly)(target)
: await safeReadPkgJson(target);
if (manifest == null) {
// There's a directory in node_modules without package.json: ${target}.

@@ -100,3 +120,3 @@ // This used to be a warning but it didn't really cause any issues.

async function getPackageBinsFromManifest(manifest, pkgDir) {
const cmds = await package_bins_1.default(manifest, pkgDir);
const cmds = await (0, package_bins_1.default)(manifest, pkgDir);
return cmds.map((cmd) => ({

@@ -110,12 +130,12 @@ ...cmd,

async function linkBin(cmd, binsDir) {
const externalBinPath = path.join(binsDir, cmd.name);
const externalBinPath = path_1.default.join(binsDir, cmd.name);
if (EXECUTABLE_SHEBANG_SUPPORTED) {
await fs.chmod(cmd.path, 0o755);
await fs_1.promises.chmod(cmd.path, 0o755);
}
let nodePath = await getBinNodePaths(cmd.path);
const binsParentDir = path.dirname(binsDir);
if (path.relative(cmd.path, binsParentDir) !== '') {
const binsParentDir = path_1.default.dirname(binsDir);
if (path_1.default.relative(cmd.path, binsParentDir) !== '') {
nodePath = R.union(nodePath, await getBinNodePaths(binsParentDir));
}
return cmdShim(cmd.path, externalBinPath, {
return (0, cmd_shim_1.default)(cmd.path, externalBinPath, {
createPwshFile: cmd.makePowerShellShim,

@@ -126,9 +146,9 @@ nodePath,

async function getBinNodePaths(target) {
const targetDir = path.dirname(target);
const targetRealPath = await fs.realpath(targetDir);
return R.union(Module['_nodeModulePaths'](targetRealPath), Module['_nodeModulePaths'](targetDir));
const targetDir = path_1.default.dirname(target);
const targetRealPath = await fs_1.promises.realpath(targetDir);
return R.union(module_1.default['_nodeModulePaths'](targetRealPath), module_1.default['_nodeModulePaths'](targetDir));
}
async function safeReadPkgJson(pkgDir) {
try {
return await read_package_json_1.fromDir(pkgDir);
return await (0, read_package_json_1.fromDir)(pkgDir);
}

@@ -135,0 +155,0 @@ catch (err) {

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

@@ -12,13 +12,13 @@ "main": "lib/index.js",

"engines": {
"node": ">=10.16"
"node": ">=12.17"
},
"scripts": {
"lint": "eslint -c ../../eslint.json src/**/*.ts test/**/*.ts",
"pre_test": "ncp test/fixtures test/fixtures_for_testing",
"post_test": "rimraf test/fixtures_for_testing",
"_test": "jest",
"pretest": "ncp test/fixtures test/fixtures_for_testing",
"posttest": "rimraf test/fixtures_for_testing",
"_test": "pnpm pretest && jest && pnpm posttest",
"test": "pnpm run compile && pnpm run _test",
"prepublishOnly": "pnpm run compile",
"fix": "tslint -c tslint.json --project . --fix",
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build"
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build && pnpm run lint -- --fix"
},

@@ -30,3 +30,2 @@ "repository": "https://github.com/pnpm/pnpm/blob/master/packages/link-bins",

],
"author": "Zoltan Kochan <z@kochan.io> (https://www.kochan.io/)",
"license": "MIT",

@@ -38,12 +37,11 @@ "bugs": {

"dependencies": {
"@pnpm/error": "1.4.0",
"@pnpm/package-bins": "4.1.0",
"@pnpm/read-modules-dir": "2.0.3",
"@pnpm/read-package-json": "4.0.0",
"@pnpm/read-project-manifest": "1.1.7",
"@pnpm/types": "6.4.0",
"@pnpm/error": "2.0.0",
"@pnpm/package-bins": "5.0.0",
"@pnpm/read-modules-dir": "3.0.0",
"@pnpm/read-package-json": "5.0.0",
"@pnpm/read-project-manifest": "2.0.0",
"@pnpm/types": "7.0.0",
"@zkochan/cmd-shim": "^5.0.0",
"is-subdir": "^1.1.1",
"is-windows": "^1.0.2",
"mz": "^2.7.0",
"normalize-path": "^3.0.0",

@@ -55,5 +53,4 @@ "p-settle": "^4.1.1",

"@types/is-windows": "^1.0.0",
"@types/mz": "^2.7.3",
"@types/ncp": "^2.0.4",
"@types/node": "^14.14.22",
"@types/node": "^14.14.33",
"@types/normalize-path": "^3.0.0",

@@ -60,0 +57,0 @@ "@types/ramda": "^0.27.35",

@@ -30,2 +30,2 @@ # @pnpm/link-bins

[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io/)
[MIT](./LICENSE)

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