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.2.0 to 6.2.1

51

lib/index.js

@@ -26,7 +26,8 @@ "use strict";

const partition_1 = __importDefault(require("ramda/src/partition"));
const IS_WINDOWS = is_windows_1.default();
const fix_bin_1 = __importDefault(require("bin-links/lib/fix-bin"));
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

@@ -41,4 +42,4 @@ if (allDeps === null)

? undefined
: new Set(Object.keys(manifest_utils_1.getAllDependenciesFromManifest(opts.projectManifest)));
const allCmds = unnest_1.default((await Promise.all(allDeps
: new Set(Object.keys((0, manifest_utils_1.getAllDependenciesFromManifest)(opts.projectManifest)));
const allCmds = (0, unnest_1.default)((await Promise.all(allDeps
.map((alias) => {

@@ -52,5 +53,5 @@ var _a;

})
.filter(({ depDir }) => !is_subdir_1.default(depDir, binsDir)) // Don't link own bins
.filter(({ depDir }) => !(0, is_subdir_1.default)(depDir, binsDir)) // Don't link own bins
.map(async ({ depDir, isDirectDependency, nodeExecPath }) => {
const target = normalize_path_1.default(depDir);
const target = (0, normalize_path_1.default)(depDir);
const cmds = await getPackageBins(pkgBinOpts, target, nodeExecPath);

@@ -64,3 +65,3 @@ return cmds.map((cmd) => ({ ...cmd, isDirectDependency }));

function preferDirectCmds(allCmds) {
const [directCmds, hoistedCmds] = partition_1.default((cmd) => cmd.isDirectDependency === true, allCmds);
const [directCmds, hoistedCmds] = (0, partition_1.default)((cmd) => cmd.isDirectDependency === true, allCmds);
const usedDirectCmds = new Set(directCmds.map((directCmd) => directCmd.name));

@@ -75,3 +76,3 @@ return [

return [];
const allCmds = unnest_1.default((await Promise.all(pkgs
const allCmds = (0, unnest_1.default)((await Promise.all(pkgs
.map(async (pkg) => getPackageBinsFromManifest(pkg.manifest, pkg.location, pkg.nodeExecPath))))

@@ -86,6 +87,6 @@ .filter((cmds) => cmds.length));

await fs_1.promises.mkdir(binsDir, { recursive: true });
const [cmdsWithOwnName, cmdsWithOtherNames] = partition_1.default(({ ownName }) => ownName, allCmds);
const results1 = await p_settle_1.default(cmdsWithOwnName.map(async (cmd) => linkBin(cmd, binsDir, opts)));
const usedNames = fromPairs_1.default(cmdsWithOwnName.map((cmd) => [cmd.name, cmd.name]));
const results2 = await p_settle_1.default(cmdsWithOtherNames.map(async (cmd) => {
const [cmdsWithOwnName, cmdsWithOtherNames] = (0, partition_1.default)(({ ownName }) => ownName, allCmds);
const results1 = await (0, p_settle_1.default)(cmdsWithOwnName.map(async (cmd) => linkBin(cmd, binsDir, opts)));
const usedNames = (0, fromPairs_1.default)(cmdsWithOwnName.map((cmd) => [cmd.name, cmd.name]));
const results2 = await (0, p_settle_1.default)(cmdsWithOtherNames.map(async (cmd) => {
if (usedNames[cmd.name]) {

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

const real = await fs_1.promises.realpath(filename);
return normalize_path_1.default(real).includes('/node_modules/');
return (0, normalize_path_1.default)(real).includes('/node_modules/');
}
async function getPackageBins(opts, target, nodeExecPath) {
const manifest = opts.allowExoticManifests
? await read_project_manifest_1.safeReadProjectManifestOnly(target)
? await (0, read_project_manifest_1.safeReadProjectManifestOnly)(target)
: await safeReadPkgJson(target);

@@ -120,3 +121,3 @@ if (manifest == null) {

}
if (isEmpty_1.default(manifest.bin) && !await isFromModules(target)) {
if ((0, isEmpty_1.default)(manifest.bin) && !await isFromModules(target)) {
opts.warn(`Package in ${target} must have a non-empty bin field to get bin linked.`, 'EMPTY_BIN');

@@ -130,3 +131,3 @@ }

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

@@ -142,5 +143,2 @@ ...cmd,

const externalBinPath = path_1.default.join(binsDir, cmd.name);
if (EXECUTABLE_SHEBANG_SUPPORTED) {
await fs_1.promises.chmod(cmd.path, 0o755);
}
let nodePath;

@@ -151,6 +149,6 @@ if ((opts === null || opts === void 0 ? void 0 : opts.extendNodePath) !== false) {

if (path_1.default.relative(cmd.path, binsParentDir) !== '') {
nodePath = union_1.default(nodePath, await getBinNodePaths(binsParentDir));
nodePath = (0, union_1.default)(nodePath, await getBinNodePaths(binsParentDir));
}
}
return cmd_shim_1.default(cmd.path, externalBinPath, {
await (0, cmd_shim_1.default)(cmd.path, externalBinPath, {
createPwshFile: cmd.makePowerShellShim,

@@ -160,2 +158,7 @@ nodePath,

});
// ensure that bin are executable and not containing
// windows line-endings(CRLF) on the hashbang line
if (EXECUTABLE_SHEBANG_SUPPORTED) {
await (0, fix_bin_1.default)(cmd.path, 0o755);
}
}

@@ -165,9 +168,9 @@ async function getBinNodePaths(target) {

const targetRealPath = await fs_1.promises.realpath(targetDir);
return union_1.default(module_1.default['_nodeModulePaths'](targetRealPath), module_1.default['_nodeModulePaths'](targetDir));
return (0, union_1.default)(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);
}
catch (err) {
catch (err) { // eslint-disable-line
if (err.code === 'ENOENT') {

@@ -174,0 +177,0 @@ return null;

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

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

"keywords": [
"pnpm6",
"pnpm",

@@ -34,2 +35,3 @@ "bin"

"@zkochan/cmd-shim": "^5.2.1",
"bin-links": "^2.3.0",
"is-subdir": "^1.1.1",

@@ -36,0 +38,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