Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit ca55986

Browse files
committedJul 28, 2019
Added another path helper
1 parent a8a39fc commit ca55986

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,16 @@ function isNotRelative (file) {
183183
return isRelative(file) && file[0] !== '.'
184184
}
185185

186+
function joinAndResolvePath (basePath, targetPath) {
187+
return path.resolve(path.join(basePath, targetPath))
188+
}
189+
186190
function resolveDefaultEntriesPaths (opts) {
187191
const pkgPath = opts.path
188192
const pkgDir = path.dirname(pkgPath)
189193
const pkg = opts.package
190194

191-
const mainPath = path.resolve(pkg.main || path.join(pkgDir, 'index.js'))
195+
const mainPath = joinAndResolvePath(pkgDir, pkg.main || 'index.js')
192196

193197
let paths = []
194198

@@ -198,10 +202,11 @@ function resolveDefaultEntriesPaths (opts) {
198202
// Add the path of binaries
199203
if (pkg.bin) {
200204
if (typeof pkg.bin === 'string') {
205+
paths.push(joinAndResolvePath(pkgDir, pkg.bin))
201206
} else {
202207
Object.keys(pkg.bin).forEach(cmdName => {
203208
const cmd = pkg.bin[cmdName]
204-
paths.push(path.resolve(path.join(pkgDir, cmd)))
209+
paths.push(joinAndResolvePath(pkgDir, cmd))
205210
})
206211
}
207212
}

0 commit comments

Comments
 (0)
This repository has been archived.