@pnpm/link-bins
Advanced tools
Comparing version 2.0.1 to 3.0.0
@@ -1,1 +0,1 @@ | ||
export default function (modules: string): Promise<string[]>; | ||
export default function (modules: string, warn: (msg: string) => void): Promise<string[]>; |
@@ -11,3 +11,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const logger_1 = require("@pnpm/logger"); | ||
const flatten = require("arr-flatten"); | ||
@@ -17,7 +16,7 @@ const fs = require("mz/fs"); | ||
const path = require("path"); | ||
function default_1(modules) { | ||
function default_1(modules, warn) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const dirs = yield getDirectories(modules); | ||
const dirs = yield getDirectories(modules, warn); | ||
const subdirs = yield Promise.all(dirs.map((dir) => { | ||
return isScopedPkgsDir(dir) ? getDirectories(dir) : Promise.resolve([dir]); | ||
return isScopedPkgsDir(dir) ? getDirectories(dir, warn) : Promise.resolve([dir]); | ||
})); | ||
@@ -28,3 +27,3 @@ return flatten(subdirs); | ||
exports.default = default_1; | ||
function getDirectories(srcPath) { | ||
function getDirectories(srcPath, warn) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -51,3 +50,3 @@ let dirs; | ||
throw err; | ||
logger_1.default.warn(`Cannot find file at ${absolutePath} although it was listed by readdir`); | ||
warn(`Cannot find file at ${absolutePath} although it was listed by readdir`); | ||
return false; | ||
@@ -54,0 +53,0 @@ } |
import { PackageJson } from '@pnpm/types'; | ||
declare const _default: (modules: string, binPath: string, exceptPkgName?: string | undefined) => Promise<void>; | ||
declare const _default: (modules: string, binPath: string, opts: { | ||
warn: (msg: string) => void; | ||
}) => Promise<void>; | ||
export default _default; | ||
@@ -7,2 +9,4 @@ export declare function linkBinsOfPackages(pkgs: Array<{ | ||
location: string; | ||
}>, binsTarget: string): Promise<void>; | ||
}>, binsTarget: string, opts: { | ||
warn: (msg: string) => void; | ||
}): Promise<void>; |
@@ -11,3 +11,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const logger_1 = require("@pnpm/logger"); | ||
const package_bins_1 = require("@pnpm/package-bins"); | ||
@@ -25,12 +24,11 @@ const read_package_json_1 = require("@pnpm/read-package-json"); | ||
const POWER_SHELL_IS_SUPPORTED = isWindows(); | ||
exports.default = (modules, binPath, exceptPkgName) => __awaiter(this, void 0, void 0, function* () { | ||
const pkgDirs = yield getPkgDirs_1.default(modules); | ||
exports.default = (modules, binPath, opts) => __awaiter(this, void 0, void 0, function* () { | ||
const pkgDirs = yield getPkgDirs_1.default(modules, opts.warn); | ||
const allCmds = R.unnest((yield Promise.all(pkgDirs | ||
.map(normalizePath) | ||
.filter((pkgDir) => !exceptPkgName || !pkgDir.endsWith(`/${exceptPkgName}`)) | ||
.map(getPackageBins))) | ||
.map((target) => getPackageBins(target, opts.warn)))) | ||
.filter((cmds) => cmds.length)); | ||
return linkBins(allCmds, binPath); | ||
return linkBins(allCmds, binPath, opts); | ||
}); | ||
function linkBinsOfPackages(pkgs, binsTarget) { | ||
function linkBinsOfPackages(pkgs, binsTarget, opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -42,7 +40,7 @@ if (!pkgs.length) | ||
.filter((cmds) => cmds.length)); | ||
return linkBins(allCmds, binsTarget); | ||
return linkBins(allCmds, binsTarget, opts); | ||
}); | ||
} | ||
exports.linkBinsOfPackages = linkBinsOfPackages; | ||
function linkBins(allCmds, binPath) { | ||
function linkBins(allCmds, binPath, opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -57,3 +55,3 @@ if (!allCmds.length) | ||
if (usedNames[cmd.name]) { | ||
logger_1.default.warn(`Cannot link bin "${cmd.name}" of "${cmd.pkgName}" to "${binPath}". A package called "${usedNames[cmd.name]}" already has its bin linked.`); | ||
opts.warn(`Cannot link bin "${cmd.name}" of "${cmd.pkgName}" to "${binPath}". A package called "${usedNames[cmd.name]}" already has its bin linked.`); | ||
return; | ||
@@ -66,7 +64,7 @@ } | ||
} | ||
function getPackageBins(target) { | ||
function getPackageBins(target, warn) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const pkg = yield safeReadPkg(target); | ||
if (!pkg) { | ||
logger_1.default.warn(`There's a directory in node_modules without package.json: ${target}`); | ||
warn(`There's a directory in node_modules without package.json: ${target}`); | ||
return []; | ||
@@ -73,0 +71,0 @@ } |
{ | ||
"name": "@pnpm/link-bins", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Link bins to node_modules/.bin", | ||
@@ -35,5 +35,2 @@ "main": "lib/index.js", | ||
"homepage": "https://github.com/pnpm/link-bins#readme", | ||
"peerDependencies": { | ||
"@pnpm/logger": "^1.0.0" | ||
}, | ||
"dependencies": { | ||
@@ -56,4 +53,4 @@ "@pnpm/package-bins": "^1.0.0", | ||
"devDependencies": { | ||
"@pnpm/logger": "^1.0.1", | ||
"@types/path-exists": "^3.0.0", | ||
"@types/sinon": "^5.0.1", | ||
"@types/tape": "^4.2.31", | ||
@@ -66,2 +63,3 @@ "@types/tempy": "^0.1.0", | ||
"rimraf": "^2.6.2", | ||
"sinon": "^6.1.3", | ||
"tape": "^4.8.0", | ||
@@ -68,0 +66,0 @@ "tempy": "^0.2.1", |
@@ -12,3 +12,3 @@ # @pnpm/link-bins | ||
```sh | ||
npm i -S @pnpm/logger @pnpm/link-bins | ||
npm i -S @pnpm/link-bins | ||
``` | ||
@@ -21,6 +21,8 @@ | ||
await linkBins('node_modules', 'node_modules/.bin') | ||
function warn (msg) { console.warn(msg) } | ||
await linkBins('node_modules', 'node_modules/.bin', {warn}) | ||
const packages = [{manifest: packageJson, location: pathToPackage}] | ||
await linkBinsOfPackages(packages, 'node_modules/.bin') | ||
await linkBinsOfPackages(packages, 'node_modules/.bin', {warn}) | ||
``` | ||
@@ -27,0 +29,0 @@ |
Sorry, the diff of this file is not supported yet
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
14
172
31
15982
15