Git Product home page Git Product logo

module-details-from-path's Introduction

module-details-from-path

Extract the Node.js module details like name and base path given an absolute path to a file inside the module.

Build status js-standard-style

Installation

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

Usage

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

var 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

module-details-from-path's People

Contributors

fnogatz avatar vdeturckheim avatar watson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

module-details-from-path's Issues

Requires modules to be in a `node_modules` directory

Right now, the way the library works is that it requires the module to be in a node_modules directory. This isn't great because it doesn't work well with monorepos or work at all with test frameworks that aggressively avoid running tests for packages located in a node_modules directory.

One way to get around this would be to check if the module we're trying to get info from is in a node_modules directory, if it is, then great, we can use the existing technique. But if it's not, then let's check the parent directories for a package.json. If we find one, then that becomes the base directory for the package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.