mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-25 03:27:07 -05:00
* chore(scripts): typecheck-only * feat: change all configuration * feat: include pnpm/ and pnpm/test/ * chore(deps): remove unused dependency * refactor(typescript-only): use find-packages * refactor(typescript-only): refactor paths * fix: typescript-only * fix: update compile-only * fix: compile pnpm * fix: windows * fix: windows * chore: meta-updater * refactor(tsconfig): remove explicit composite * fix: path in windows * feat: don't depend on cwd --------- Co-authored-by: Zoltan Kochan <z@kochan.io>
dependency-path
Utilities for working with symlinked node_modules
Like path but for packages in a symlinked node_modules. Symlinked node_modules is a unique dependencies layout that
pnpm creates.
Installation
pnpm add dependency-path
Usage
const dependencyPath = require('dependency-path')
const registry = 'https://registry.npmjs.org/'
console.log(dependencyPath.isAbsolute('/foo/1.0.0'))
//> false
// it is confusing currently because relative starts with /.
// It will be changed in the future to vice versa
console.log(dependencyPath.resolve(registry, '/foo/1.0.0'))
//> registry.npmjs.org/foo/1.0.0
console.log(dependencyPath.relative(registry, 'registry.npmjs.org/foo/1.0.0'))
//> /foo/1.0.0
console.log(dependencyPath.refToAbsolute('1.0.1', 'foo', registry))
//> registry.npmjs.org/foo/1.0.1
console.log(dependencyPath.refToAbsolute('github.com/foo/bar/twe0jger043t0ew', 'foo', registry))
//> github.com/foo/bar/twe0jger043t0ew
console.log(dependencyPath.refToRelative('1.0.1', 'foo', registry))
//> /foo/1.0.1
console.log(dependencyPath.parse('/foo/2.0.0'))
//> { isAbsolute: false, name: 'foo', version: '2.0.0' }
License
MIT