findout
Find out a module.
Last updated a year ago by okunishinishi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install findout 
SYNC missed versions from official npm registry.

findout

Build Status Code Climate Code Coverage npm Version JS Standard

Find out a module.

Installation

npm install findout --save

Usage

findout(name) works like require(), but has a lot more locations to search.

'use strict'

const findout = require('findout')

// Resolve a module path.
let pathOfFoo = findout.resolve('foo')

// Find and require a module.
let foo = findout('foo', {
  cwd: __dirname // Lookup from current directory.
})


How It Works

When you call findout for "foo" with '/bar/baz' as current working directory:

findout('foo', {
  cwd: '/bar/baz'
})

and it will try the following ways,

  1. require('foo')
  2. require('/bar/baz/foo')
  3. require('/bar/baz/node_modules/foo')
  4. require('/bar/foo')
  5. require('/bar/node_modules/foo')
  6. require('/foo')
  7. require('/node_modules/foo')

If it still can't find any, throws an error.

Options

Key Type Default Description
cwd string process.cwd() Working directory path.
safe boolean false No throw when not found.

License

This software is released under the MIT License.

Current Tags

  • 3.0.2                                ...           latest (a year ago)

17 Versions

  • 3.0.2                                ...           a year ago
  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.1.2                                ...           4 years ago
  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago

Copyright 2014 - 2017 © taobao.org |