1.1.2 • Published 6 years ago

sexy-require v1.1.2

Weekly downloads
122
License
MIT License
Repository
github
Last release
6 years ago

💃🏻 Sexy require v 1.1

No more ugly path inside the require.

const user = require('../../../database/user') // 👎 what you have
// OR
const user = require('$db/user') // 👍 no matter how deep you are
const product = require('/database/product') // 👍 alias or pathing from application directory

Getting started

Three simple steps to use it. 1. Install the package: npm install sexy-require --save

  1. Include require('sexy-require') once on the top of your main application file.
require('sexy-require')
const routers = require('/routers')
const api = require('$api')
...
  1. Optional step. Path configuration can be defined in .paths file on root directory of your project.
$db = /server/database
$api-v1 = /server/api/legacy
$api-v2 = /server/api/v2

List of paths

Anywhere in your project you can get the defined shortcut paths:

const path = require(`sexy-require`)
console.log(path.$db) // -> '/full/path/to/app/server/database'

Changelog

v 1.1

  • Seamless module require. If a given path doesn't exist in the app directory it will be ignored by sexy-require.

v 1.0

  • definition of path shortcuts moved from package.json to .paths config file
  • depending modules can use sexy-require too, previously it was not possible
  • supporting pathing from root directory, now it is not required to define shortcuts
  • caching and optimized code for higher performance

v 0.1

  • returns defined shortcut list with absolute path
  • minor bug fixes
1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.0

7 years ago

0.0.10

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago