# realize-package-specifier

> Like npm-package-arg, but more so, producing full file paths and differentiating local tar and directory sources.

Latest version **3.0.3** (published 2016-04-21) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install realize-package-specifier
pnpm add realize-package-specifier
yarn add realize-package-specifier
bun add realize-package-specifier
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2016-04-21 |
| First published | 2014-09-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Rebecca Turner |
| Maintainers | iarna, othiym23, zkat |

## Links

- npm: https://www.npmjs.com/package/realize-package-specifier
- Repository: https://github.com/npm/realize-package-specifier
- Issues: https://github.com/npm/realize-package-specifier/issues
- npm.io page: https://npm.io/package/realize-package-specifier

## Dependencies (2)

- [dezalgo](https://npm.io/package/dezalgo.md) ^1.0.1
- [npm-package-arg](https://npm.io/package/npm-package-arg.md) ^4.1.1

## Recent versions

- 3.0.3 (latest) — 2016-04-21
- 3.0.2 — 2016-04-20
- 3.0.1 — 2015-05-21
- 3.0.0 — 2015-04-07
- 2.2.0 — 2015-01-25
- 1.3.0 — 2014-11-24
- 2.1.0 — 2014-11-24
- 2.0.0 — 2014-10-28
- 1.2.0 — 2014-10-02
- 1.1.0 — 2014-10-01
- 1.0.2 — 2014-09-30
- 1.0.1 — 2014-09-30
- 1.0.0 — 2014-09-29

## README

realize-package-specifier
-------------------------

Parse a package specifier, peeking at the disk to differentiate between
local tarballs, directories and named modules.  This implements the logic
used by `npm install` and `npm cache` to determine where to get packages
from.

```javascript
var realizePackageSpecifier = require("realize-package-specifier")
realizePackageSpecifier("foo.tar.gz", ".", function (err, package) {
    …
})
```

## Using

* realizePackageSpecifier(*spec*, [*where*,] *callback*)

Parses *spec* using `npm-package-arg` and then uses stat to check to see if
it refers to a local tarball or package directory.  Stats are done relative
to *where*.  If it does then the local module is loaded.  If it doesn't then
target is left as a remote package specifier.  Package directories are
recognized by the presence of a package.json in them.

*spec* -- a package specifier, like: `foo@1.2`, or `foo@user/foo`, or
`http://x.com/foo.tgz`, or `git+https://github.com/user/foo`

*where* (optional, default: .) -- The directory in which we should look for
local tarballs or package directories.

*callback* function(*err*, *result*) -- Called once we've determined what
kind of specifier this is.  The *result* object will be very like the one
returned by `npm-package-arg` except with three differences: 1) There's a
new type of `directory`.  2) The `local` type only refers to tarballs.  2)
For all `local` and `directory` type results spec will contain the full path of
the local package.

## Result Object

The full definition of the result object is:

* `name` - If known, the `name` field expected in the resulting pkg.
* `type` - One of the following strings:
  * `git` - A git repo
  * `hosted` - A hosted project, from github, bitbucket or gitlab. Originally
    either a full url pointing at one of these services or a shorthand like
    `user/project` or `github:user/project` for github or `bitbucket:user/project`
    for bitbucket.
  * `tag` - A tagged version, like `"foo@latest"`
  * `version` - A specific version number, like `"foo@1.2.3"`
  * `range` - A version range, like `"foo@2.x"`
  * `local` - A local file path
  * `directory` - A local package directory
  * `remote` - An http url (presumably to a tgz)
* `spec` - The "thing".  URL, the range, git repo, etc.
* `hosted` - If type=hosted this will be an object with the following keys:
  * `type` - github, bitbucket or gitlab
  * `ssh` - The ssh path for this git repo
  * `sshurl` - The ssh URL for this git repo
  * `https` - The HTTPS URL for this git repo
  * `directUrl` - The URL for the package.json in this git repo
* `raw` - The original un-modified string that was provided.
* `rawSpec` - The part after the `name@...`, as it was originally
  provided.
* `scope` - If a name is something like `@org/module` then the `scope`
  field will be set to `org`.  If it doesn't have a scoped name, then
  scope is `null`.

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