# global-path

> Set Global Path

Latest version **1.1.0** (published 2017-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install global-path
pnpm add global-path
yarn add global-path
bun add global-path
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-06-02 |
| First published | 2017-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | oknoorap |
| Maintainers | oknoorap |
| Keywords | path, global-path |

## Links

- npm: https://www.npmjs.com/package/global-path
- Repository: https://github.com/oknoorap/global-path
- Homepage: https://github.com/oknoorap/global-path#readme
- Issues: https://github.com/oknoorap/global-path/issues
- npm.io page: https://npm.io/package/global-path

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-06-02
- 1.0.0 — 2017-06-01

## README

# :ghost: global-path
Set Global Path Elegantly. When you have directory structure with ugly nested depth it will bad for maintenance. Eureka, now you want to register your path globally.

Turn your code
```javascript
const dbinit = require('../../../helpers/db/init')
```

Into this code
```javascript
require('global-path')('helpers', '@/../../helpers/')

const dbinit = __helpers.require('db/init')
```

## Installation

```shell
$ npm install global-path --save

or

$ yarn add global-path
```

## Usage
You should register alias in your main file or in any file before require everything.
`@` symbol is an alias of `__dirname`. If you're use eslint you can call it via `global`.

```javascript
// index.js
require('global-path')('config', '@/src/config/')
__config.require('myconfig')

// bin/cli with no prefix
require('global-path')('utils', '@/../src/utils')
console.log(utils.path, global.utils.path) // Print path
utils.require('string')
```

## Params
`globalPath (alias: string, path: string, prefix?: string)`

## License
MIT © [oknoorap](https://github.com/oknoorap)

---
_Source: https://npm.io/package/global-path · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
