]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/realize-package-specifier/README.md
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / realize-package-specifier / README.md
1 realize-package-specifier
2 -------------------------
3
4 Parse a package specifier, peeking at the disk to differentiate between
5 local tarballs, directories and named modules.  This implements the logic
6 used by `npm install` and `npm cache` to determine where to get packages
7 from.
8
9 ```javascript
10 var realizePackageSpecifier = require("realize-package-specifier")
11 realizePackageSpecifier("foo.tar.gz", ".", function (err, package) {
12     …
13 })
14 ```
15
16 ## Using
17
18 * realizePackageSpecifier(*spec*, [*where*,] *callback*)
19
20 Parses *spec* using `npm-package-arg` and then uses stat to check to see if
21 it refers to a local tarball or package directory.  Stats are done relative
22 to *where*.  If it does then the local module is loaded.  If it doesn't then
23 target is left as a remote package specifier.  Package directories are
24 recognized by the presence of a package.json in them.
25
26 *spec* -- a package specifier, like: `foo@1.2`, or `foo@user/foo`, or
27 `http://x.com/foo.tgz`, or `git+https://github.com/user/foo`
28
29 *where* (optional, default: .) -- The directory in which we should look for
30 local tarballs or package directories.
31
32 *callback* function(*err*, *result*) -- Called once we've determined what
33 kind of specifier this is.  The *result* object will be very like the one
34 returned by `npm-package-arg` except with three differences: 1) There's a
35 new type of `directory`.  2) The `local` type only refers to tarballs.  2)
36 For all `local` and `directory` type results spec will contain the full path of
37 the local package.
38
39 ## Result Object
40
41 The full definition of the result object is:
42
43 * `name` - If known, the `name` field expected in the resulting pkg.
44 * `type` - One of the following strings:
45   * `git` - A git repo
46   * `hosted` - A hosted project, from github, bitbucket or gitlab. Originally
47     either a full url pointing at one of these services or a shorthand like
48     `user/project` or `github:user/project` for github or `bitbucket:user/project`
49     for bitbucket.
50   * `tag` - A tagged version, like `"foo@latest"`
51   * `version` - A specific version number, like `"foo@1.2.3"`
52   * `range` - A version range, like `"foo@2.x"`
53   * `local` - A local file path
54   * `directory` - A local package directory
55   * `remote` - An http url (presumably to a tgz)
56 * `spec` - The "thing".  URL, the range, git repo, etc.
57 * `hosted` - If type=hosted this will be an object with the following keys:
58   * `type` - github, bitbucket or gitlab
59   * `ssh` - The ssh path for this git repo
60   * `sshurl` - The ssh URL for this git repo
61   * `https` - The HTTPS URL for this git repo
62   * `directUrl` - The URL for the package.json in this git repo
63 * `raw` - The original un-modified string that was provided.
64 * `rawSpec` - The part after the `name@...`, as it was originally
65   provided.
66 * `scope` - If a name is something like `@org/module` then the `scope`
67   field will be set to `org`.  If it doesn't have a scoped name, then
68   scope is `null`.
69