From 0320bb7db2659784018c2142c85e2066e4f74fa7 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Mon, 15 Jul 2019 18:10:12 +0200 Subject: [PATCH] Minor refactoring of bin resolving --- index.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 5cf6624..b961001 100644 --- a/index.js +++ b/index.js @@ -201,14 +201,13 @@ function resolveDefaultEntriesPaths (opts) { // Add the path of binaries if (pkg.bin) { - if (typeof pkg.bin === 'string') { - paths.push(joinAndResolvePath(pkgDir, pkg.bin)) - } else { - Object.keys(pkg.bin).forEach(cmdName => { - const cmd = pkg.bin[cmdName] - paths.push(joinAndResolvePath(pkgDir, cmd)) - }) - } + const binPaths = typeof pkg.bin === 'string' + ? [pkg.bin] + : Object.values(pkg.bin) + + binPaths.forEach(cmd => { + paths.push(joinAndResolvePath(pkgDir, cmd)) + }) } return paths