Skip to content

Commit

Permalink
refactor: Exclude mapBinaries
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Sep 8, 2024
1 parent a14b83f commit fd7cbfd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 32 deletions.
18 changes: 18 additions & 0 deletions lib/setup-dependency/binary-handler/map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";

const { join, resolve } = require("path")
, resolveBinariesDict = require("../../resolve-package-binaries-dict")
, binaryHandler = require("./");

module.exports = async ({ name, path, dependentContext }) => {
const binDict = resolveBinariesDict(path);
if (!binDict) return;
await Promise.all(
Object.entries(binDict).map(async ([targetName, linkedPath]) => {
await binaryHandler.set(
join("../", name, linkedPath),
resolve(dependentContext.path, "node_modules/.bin", targetName)
);
})
);
};
50 changes: 18 additions & 32 deletions lib/setup-dependency/install-external/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
"use strict";

const optionalChaining = require("es5-ext/optional-chaining")
, { join, resolve, relative, dirname } = require("path")
, copyDir = require("fs2/copy-dir")
, isDirectory = require("fs2/is-directory")
, isSymlink = require("fs2/is-symlink")
, symlink = require("fs2/symlink")
, rm = require("fs2/rm")
, lstat = require("fs2/lstat")
, log = require("log").get("npm-cross-link")
, getPackageJson = require("../../get-package-json")
, muteErrorIfOptional = require("../mute-error-if-optional")
, cachePackage = require("../../cache-package")
, resolveBinariesDict = require("../../resolve-package-binaries-dict")
, resolveExternalContext = require("../../resolve-external-context")
, NpmCrossLinkError = require("../../npm-cross-link-error")
, resolveLogLevel = require("../../utils/resolve-log-level")
, binaryHandler = require("../binary-handler")
, isCoherent = require("../binary-handler/is-coherent")
, resolveIsToBeLinked = require("./resolve-is-to-be-linked");

const mapBinaries = async ({ name, path, dependentContext }) => {
const binDict = resolveBinariesDict(path);
if (!binDict) return;
await Promise.all(
Object.entries(binDict).map(async ([targetName, linkedPath]) => {
await binaryHandler.set(
join("../", name, linkedPath),
resolve(dependentContext.path, "node_modules/.bin", targetName)
);
})
);
};
const optionalChaining = require("es5-ext/optional-chaining")
, { relative, dirname } = require("path")
, copyDir = require("fs2/copy-dir")
, isDirectory = require("fs2/is-directory")
, isSymlink = require("fs2/is-symlink")
, symlink = require("fs2/symlink")
, rm = require("fs2/rm")
, lstat = require("fs2/lstat")
, log = require("log").get("npm-cross-link")
, getPackageJson = require("../../get-package-json")
, muteErrorIfOptional = require("../mute-error-if-optional")
, cachePackage = require("../../cache-package")
, resolveExternalContext = require("../../resolve-external-context")
, NpmCrossLinkError = require("../../npm-cross-link-error")
, resolveLogLevel = require("../../utils/resolve-log-level")
, mapBinaries = require("../binary-handler/map")
, isCoherent = require("../binary-handler/is-coherent")
, resolveIsToBeLinked = require("./resolve-is-to-be-linked");

module.exports = async (dependencyContext, userConfiguration, progressData) => {
const externalContext = await resolveExternalContext(dependencyContext, progressData);
Expand Down

0 comments on commit fd7cbfd

Please sign in to comment.