module-details-from-path

Resolve npm package details, like name and base path, given an absolute path to a file inside a package

MIT 5 个版本
安装
npm install module-details-from-path
yarn add module-details-from-path
pnpm add module-details-from-path
bun add module-details-from-path
README

module-details-from-path

Resolve npm package details, like name and base path, given an absolute path to a file inside a package.

js-standard-style

Installation

npm install module-details-from-path --save

Usage

const assert = require('assert')
const parse = require('module-details-from-path')

const path = '/Users/watson/code/node_modules/blackjack/node_modules/picture-tube/bin/tube.js'

assert.deepStrictEqual(parse(path), {
  name: 'picture-tube',
  basedir: '/Users/watson/code/node_modules/blackjack/node_modules/picture-tube',
  path: 'bin/tube.js'
})

Returns undefined if module details cannot be found.

License

MIT

版本列表
1.0.4 2025-04-29
1.0.3 2016-07-09
1.0.2 2016-02-09
1.0.1 2016-02-09
1.0.0 2016-02-09