npm / package-json

Programmatic API to update package.json
Other
68 stars 10 forks source link

fix: apply `securePath` to package bin #105

Closed antongolub closed 5 months ago

antongolub commented 5 months ago

What / Why

function unixifyPath (ref) {
  return ref.replace(/\\|:/g, '/')
}

function securePath (ref) {
  const secured = path.join('.', path.join('/', unixifyPath(ref)))
  return secured.startsWith('.') ? '' : secured
}

function secureAndUnixifyPath (ref) {
  return unixifyPath(securePath(ref))
}

References

continues #100, #104