Somehow this got downgraded in the last v0.6 merge. Very strange.
./npmrc
.gitignore
release/
+
+# don't ignore .npmignore files
+# these are used in some tests.
+!.npmignore
Gautham Pai <buzypi@gmail.com>
David Trejo <david.daniel.trejo@gmail.com>
Paul Vorbach <paul@vorb.de>
+George Ornbo <george@shapeshed.com>
+Tim Oxley <secoif@gmail.com>
+Tyler Green <tyler.green2@gmail.com>
+atomizer <danila.gerasimov@gmail.com>
+Rod Vagg <rod@vagg.org>
+Christian Howe <coderarity@gmail.com>
+Andrew Lunny <alunny@gmail.com>
+Henrik Hodne <dvyjones@binaryhex.com>
+Adam Blackburn <regality@gmail.com>
+Kris Windham <kriswindham@gmail.com>
+Jens Grunert <jens.grunert@gmail.com>
+Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
+Dalmais Maxence <github@maxired.fr>
+Marcus Ekwall <marcus.ekwall@gmail.com>
-Copyright 2009, 2010, 2011 Isaac Z. Schlueter (the "Author")
+Copyright 2009-2012, Isaac Z. Schlueter (the "Original Author")
All rights reserved.
MIT +no-false-attribs License
containing modifications that substantially alter, remove, or
disable functionality of the Software, outside of the documented
configuration mechanisms provided by the Software, shall be
-modified such that the Author's bug reporting email addresses and
-urls are either replaced with the contact information of the
-parties responsible for the changes, or removed entirely.
+modified such that the Original Author's bug reporting email
+addresses and urls are either replaced with the contact information
+of the parties responsible for the changes, or removed entirely.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
Except where noted, this license applies to any and all software
programs and associated documentation files created by the
-Author, when distributed with the Software.
+Original Author, when distributed with the Software.
"Node.js" and "node" trademark Joyent, Inc. npm is not officially
part of the Node.js project, and is neither owned by nor
"npm Logo" created by Mathias Pettersson and Brian Hammond,
used with permission.
-This program includes a BSDTar/LibArchive version 2.8.3-1 binary,
-originally distributed as part of the MinGW suite, compiled for
-Win32, according to the terms of the BSD license.
-See deps/basic-bsdtar-2.8.3-1-ming32-bin/basic-bsdtar.LICENSE.
-
This program uses "node-uuid", Copyright (c) 2010 Robert Kieffer,
according to the terms of the MIT license.
This program uses "request", Copyright (c) 2011 Mikeal Rogers,
according to the terms of the Apache license.
+
+This program uses "mkdirp", Copyright (c) 2010 James Halliday,
+according to the terms of the MIT/X11 license.
rsync -vazu --stats --no-implied-dirs --delete html/api/ npmjs.org:/var/www/npmjs.org/public/api
zip-publish: release
- scp release/*.zip npmjs.org:/var/www/npmjs.org/public/dist/
+ scp release/* npmjs.org:/var/www/npmjs.org/public/dist/
release:
@bash scripts/release.sh
return
}
+if (conf.versions) {
+ var v = process.versions
+ v.npm = npm.version
+ console.log(v)
+ return
+}
+
log.info("npm@"+npm.version, "using")
log.info("node@"+process.version, "using")
+++ /dev/null
-var argv = process.argv.slice(2)
- , user = argv[0] || process.getuid()
- , group = argv[1] || process.getgid()
-
-if (!isNaN(user)) user = +user
-if (!isNaN(group)) group = +group
-
-console.error([user, group])
-
-try {
- process.setgid(group)
- process.setuid(user)
- console.log(JSON.stringify({uid:+process.getuid(), gid:+process.getgid()}))
-} catch (ex) {
- console.log(JSON.stringify({error:ex.message,errno:ex.errno}))
-}
:: Created by npm, please don't edit manually.\r
-@IF EXIST "%~dp0"\"node.exe" (\r
- "%~dp0"\"node.exe" "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*\r
+@IF EXIST "%~dp0\node.exe" (\r
+ "%~dp0\node.exe" "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*\r
) ELSE (\r
- node "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*\r
-)
\ No newline at end of file
+ node "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*\r
+)\r
If the silent parameter is set to true, nothing will be output to the screen,
but the data will still be returned.
+Callback is provided an error if one occurred, the full data about which
+packages are installed and which dependencies they will receive, and a
+"lite" data object which just shows which versions are installed where.
+Note that the full data object is a circular structure, so care must be
+taken if it is serialized to JSON.
+
## CONFIGURATION
### long
## HISTORY
+### 1.1.3, 1.1.4
+
+* Update request to support HTTPS-over-HTTP proxy tunneling
+* Throw on undefined envs in config settings
+* Update which to 1.0.5
+* Fix windows UNC busyloop in findPrefix
+* Bundle nested bundleDependencies properly
+* Alias adduser to add-user
+* Doc updates (Christian Howe, Henrik Hodne, Andrew Lunny)
+* ignore logfd/outfd streams in makeEnv() (Rod Vagg)
+* shrinkwrap: Behave properly with url-installed deps
+* install: Support --save with url install targets
+* Support installing naked tars or single-file modules from urls etc.
+* init: Don't add engines section
+* Don't run make clean on rebuild
+* Added missing unicode replacement (atomizer)
+
+### 1.1.2
+
+Dave Pacheco (2):
+ add "npm shrinkwrap"
+
+Martin Cooper (1):
+ Fix #1753 Make a copy of the cached objects we'll modify.
+
+Tim Oxley (1):
+ correctly remove readme from default npm view command.
+
+Tyler Green (1):
+ fix #2187 set terminal columns to Infinity if 0
+
+isaacs (19):
+ update minimatch
+ update request
+ Experimental: single-file modules
+ Fix #2172 Don't remove global mans uninstalling local pkgs
+ Add --versions flag to show the version of node as well
+ Support --json flag for ls output
+ update request to 2.9.151
+
+### 1.1
+* Replace system tar dependency with a JS tar
+* Continue to refine
+
### 1.0
* Greatly simplified folder structure
* Install locally (bundle by default)
* `for (;;)` loops. They're actually required.
* null loops like: `while (something) ;` (But you'd better have a good
reason for doing that.)
-* case "foo": doSomething(); break
-* In front of a leading ( or [ at the start of the line.
+* `case "foo": doSomething(); break`
+* In front of a leading `(` or `[` at the start of the line.
This prevents the expression from being interpreted
as a function call or property access, respectively.
* `-l`: `--long`
* `-desc`: `--description`
* `-S`: `--save`
+* `-D`: `--save-dev`
+* `-O`: `--save-optional`
* `-y`: `--yes`
* `-n`: `--yes false`
* `ll` and `la` commands: `ls --long`
The location of npm's cache directory. See `npm-cache(1)`
+### cache-max
+
+* Default: Infinity
+* Type: Number
+
+The maximum time (in seconds) to keep items in the registry cache before
+re-checking against the registry.
+
+Note that no purging is done unless the `npm cache clean` command is
+explicitly used, and that only GET requests use the cache.
+
+### cache-min
+
+* Default: 0
+* Type: Number
+
+The minimum time (in seconds) to keep items in the registry cache before
+re-checking against the registry.
+
+Note that no purging is done unless the `npm cache clean` command is
+explicitly used, and that only GET requests use the cache.
+
### color
* Default: true on Posix, false on Windows
A proxy to use for outgoing https requests.
+### user-agent
+
+* Default: npm/{npm.version} node/{process.version}
+* Type: String
+
+Sets a User-Agent to the request header
+
### ignore
* Default: ""
### init.author.name
-* Default: "0.0.0"
+* Default: ""
* Type: String
The value `npm init` should use by default for the package author's name.
The value `npm init` should use by default for the package author's homepage.
+### json
+
+* Default: false
+* Type: Boolean
+
+Whether or not to output JSON data, rather than the normal output.
+
+This feature is currently experimental, and the output data structures
+for many commands is either not implemented in JSON yet, or subject to
+change. Only the output from `npm ls --json` is currently valid.
+
### link
* Default: false
Only works if there is already a package.json file present.
+### save-dev
+
+* Default: false
+* Type: Boolean
+
+Save installed packages to a package.json file as devDependencies.
+
+Only works if there is already a package.json file present.
+
+### save-optional
+
+* Default: false
+* Type: Boolean
+
+Save installed packages to a package.json file as optionalDependencies.
+
+Only works if there is already a package.json file present.
+
### searchopts
* Default: ""
Only relevant when specified explicitly on the command line.
+### versions
+
+* Default: false
+* Type: boolean
+
+If true, output the npm version as well as node's `process.versions`
+hash, and exit successfully.
+
+Only relevant when specified explicitly on the command line.
+
### viewer
* Default: "man" on Posix, "browser" on Windows
* d) a `<name>@<version>` that is published on the registry with (c)
* e) a `<name>@<tag>` that points to (d)
* f) a `<name>` that has a "latest" tag satisfying (e)
+* g) a `git` url that, when cloned, results in (a).
Even if you never publish your package, you can still get a lot of
benefits of using npm if you just want to write a node program (a), and
perhaps if you also want to be able to easily install it elsewhere
after packing it up into a tarball (b).
+Git urls can be of the form:
+
+ git://github.com/user/project.git#commit-ish
+ git+ssh://user@hostname:project.git#commit-ish
+ git+http://user@hostname/project/blah.git#commit-ish
+ git+https://user@hostname/project/blah.git#commit-ish
+
+The `commit-ish` can be any tag, sha, or branch which can be supplied as
+an argument to `git checkout`. The default is `master`.
+
## The package.json File
You need to have a `package.json` file in the root of your project to do
The semantic versioner for npm
+## npm-shrinkwrap(1)
+
+ Lock down dependency versions
+
## npm-star(1)
Mark your favorite packages
Search for packages
+## npm-shrinkwrap(3)
+
+ programmatically generate package shrinkwrap file
+
## npm-start(3)
Start a package
npm install <tarball file>
npm install <tarball url>
npm install <folder>
- npm install <name>
+ npm install <name> [--save|--save-dev|--save-optional]
npm install <name>@<tag>
npm install <name>@<version>
npm install <name>@<version range>
+ npm install <name>@<version range>
## DESCRIPTION
-This command installs a package, and any packages that it depends on.
+This command installs a package, and any packages that it depends on. If the
+package has a shrinkwrap file, the installation of dependencies will be driven
+by that. See npm-shrinkwrap(1).
A `package` is:
* `npm install` (in package directory, no arguments):
- Install the dependencies in the local node_modules folder.
- In global mode (ie, with `-g` or `--global` appended to the command),
- it installs the current package context (ie, the current working
- directory) as a global package.
+ Install the dependencies in the local node_modules folder.
+
+ In global mode (ie, with `-g` or `--global` appended to the command),
+ it installs the current package context (ie, the current working
+ directory) as a global package.
+
* `npm install <folder>`:
- Install a package that is sitting in a folder on the filesystem.
+
+ Install a package that is sitting in a folder on the filesystem.
* `npm install <tarball file>`:
- Install a package that is sitting on the filesystem. Note: if you just want
- to link a dev directory into your npm root, you can do this more easily by
- using `npm link`.
- Example:
+ Install a package that is sitting on the filesystem. Note: if you just want
+ to link a dev directory into your npm root, you can do this more easily by
+ using `npm link`.
+
+ Example:
- npm install ./package.tgz
+ npm install ./package.tgz
* `npm install <tarball url>`:
- Fetch the tarball url, and then install it. In order to distinguish between
- this and other options, the argument must start with "http://" or "https://"
- Example:
+ Fetch the tarball url, and then install it. In order to distinguish between
+ this and other options, the argument must start with "http://" or "https://"
+
+ Example:
+
+ npm install https://github.com/indexzero/forever/tarball/v0.5.6
+
+* `npm install <name> [--save|--save-dev|--save-optional]`:
+
+ Do a `<name>@<tag>` install, where `<tag>` is the "tag" config. (See
+ `npm-config(1)`.)
- npm install https://github.com/indexzero/forever/tarball/v0.5.6
+ In most cases, this will install the latest version
+ of the module published on npm.
-* `npm install <name>`:
- Do a `<name>@<tag>` install, where `<tag>` is the "tag" config. (See
- `npm-config(1)`)
+ Example:
- Example:
+ npm install sax
- npm install sax
+ `npm install` takes 3 exclusive, optional flags which save or update
+ the package version in your main package.json:
- **Note**: If there is a file or folder named `<name>` in the current
- working directory, then it will try to install that, and only try to
- fetch the package by name if it is not valid.
+ * `--save`: Package will appear in your `dependencies`.
+
+ * `--save-dev`: Package will appear in your `devDependencies`.
+
+ * `--save-optional`: Package will appear in your `optionalDependencies`.
+
+ Examples:
+
+ npm install sax --save
+ npm install node-tap --save-dev
+ npm install dtrace-provider --save-optional
+
+
+ **Note**: If there is a file or folder named `<name>` in the current
+ working directory, then it will try to install that, and only try to
+ fetch the package by name if it is not valid.
* `npm install <name>@<tag>`:
- Install the version of the package that is referenced by the specified tag.
- If the tag does not exist in the registry data for that package, then this
- will fail.
- Example:
+ Install the version of the package that is referenced by the specified tag.
+ If the tag does not exist in the registry data for that package, then this
+ will fail.
+
+ Example:
- npm install sax@latest
+ npm install sax@latest
* `npm install <name>@<version>`:
- Install the specified version of the package. This will fail if the version
- has not been published to the registry.
- Example:
+ Install the specified version of the package. This will fail if the version
+ has not been published to the registry.
- npm install sax@0.1.1
+ Example:
+
+ npm install sax@0.1.1
* `npm install <name>@<version range>`:
- Install a version of the package matching the specified version range. This
- will follow the same rules for resolving dependencies described in `npm-json(1)`.
- Note that most version ranges must be put in quotes so that your shell will
- treat it as a single argument.
+ Install a version of the package matching the specified version range. This
+ will follow the same rules for resolving dependencies described in `npm-json(1)`.
+
+ Note that most version ranges must be put in quotes so that your shell will
+ treat it as a single argument.
- Example:
+ Example:
- npm install sax@">=0.1.0 <0.2.0"
+ npm install sax@">=0.1.0 <0.2.0"
* `npm install <git remote url>`:
- Install a package by cloning a git remote url. The format of the git
- url is:
+ Install a package by cloning a git remote url. The format of the git
+ url is:
- <protocol>://[<user>@]<hostname><separator><path>[#<commit-ish>]
+ <protocol>://[<user>@]<hostname><separator><path>[#<commit-ish>]
- `<protocol>` is one of `git`, `git+ssh`, `git+http`, or
- `git+https`. If no `<commit-ish>` is specified, then `master` is
- used.
+ `<protocol>` is one of `git`, `git+ssh`, `git+http`, or
+ `git+https`. If no `<commit-ish>` is specified, then `master` is
+ used.
- Examples:
+ Examples:
- git+ssh://git@github.com:isaacs/npm.git#v1.0.27
- git+https://isaacs@github.com/isaacs/npm.git
- git://github.com/isaacs/npm.git#v1.0.27
+ git+ssh://git@github.com:isaacs/npm.git#v1.0.27
+ git+https://isaacs@github.com/isaacs/npm.git
+ git://github.com/isaacs/npm.git#v1.0.27
You may combine multiple arguments, and even multiple types of arguments.
For example:
* npm-folders(1)
* npm-tag(1)
* npm-rm(1)
+* npm-shrinkwrap(1)
* `""` (just an empty string) Same as `*`
* `version1 - version2` Same as `>=version1 <=version2`.
* `range1 || range2` Passes if either range1 or range2 are satisfied.
+* `git...` See 'Git URLs as Dependencies' below
For example, these are all valid:
This tarball will be downloaded and installed locally to your package at
install time.
+### Git URLs as Dependencies
+
+Git urls can be of the form:
+
+ git://github.com/user/project.git#commit-ish
+ git+ssh://user@hostname:project.git#commit-ish
+ git+http://user@hostname/project/blah.git#commit-ish
+ git+https://user@hostname/project/blah.git#commit-ish
+
+The `commit-ish` can be any tag, sha, or branch which can be supplied as
+an argument to `git checkout`. The default is `master`.
+
## devDependencies
If someone is planning on downloading and using your module in their
{ "engines" : { "node" : ">=0.1.27 <0.1.30" } }
And, like with dependencies, if you don't specify the version (or if you
-specify "*" as the version), then any version of node will do.
+specify "\*" as the version), then any version of node will do.
If you specify an "engines" field, then npm will require that "node" be
somewhere on that list. If "engines" is omitted, then npm will just assume
{ "engines" : { "npm" : "~1.0.20" } }
+## os
+
+You can specify which operating systems your
+module will run on:
+
+ "os" : [ "darwin", "linux" ]
+
+You can also blacklist instead of whitelist operating systems,
+just prepend the blacklisted os with a '!':
+
+ "os" : [ "!win32" ]
+
+The host operating system is determined by `process.platform`
+
+It is allowed to both blacklist, and whitelist, although there isn't any
+good reason to do this.
+
+## cpu
+
+If your code only runs on certain cpu architectures,
+you can specify which ones.
+
+ "cpu" : [ "x64", "ia32" ]
+
+Like the `os` option, you can also blacklist architectures:
+
+ "cpu" : [ "!arm", "!mips" ]
+
+The host architecture is determined by `process.arch`
+
## preferGlobal
If your package is primarily a command-line application that should be
This is a way to prevent accidental publication of private repositories.
If you would like to ensure that a given package is only ever published
-to a speciic registry (for example, an internal registry),
+to a specific registry (for example, an internal registry),
then use the `publishConfig` hash described below
to override the `registry` config param at publish-time.
## CONFIGURATION
+### json
+
+* Default: false
+* Type: Boolean
+
+Show information in JSON format.
+
### long
* Default: false
made available regarding the setup of npm and the current state of the
process.
+
+### path
+
+If you depend on modules that define executable scripts, like test suites,
+then those executables will be added to the `PATH` for executing the scripts.
+So, if your package.json has this:
+
+ { "name" : "foo"
+ , "dependencies" : { "bar" : "0.1.x" }
+ , "scripts": { "start" : "bar ./test" } }
+
+then you could run `npm start` to execute the `bar` script, which is exported
+into the `node_modules/.bin` directory on `npm install`.
+
### package.json vars
The package.json fields are tacked onto the `npm_package_` prefix. So, for
<p>This function should not be used programmatically. Instead, just refer
to the <code>npm.bin</code> member.</p>
</div>
-<p id="footer">bin — npm@1.1.0-2</p>
+<p id="footer">bin — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This command will launch a browser, so this command may not be the most
friendly for programmatic use.</p>
</div>
-<p id="footer">bugs — npm@1.1.0-2</p>
+<p id="footer">bugs — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/index.html">index(1)</a></li></ul>
</div>
-<p id="footer">commands — npm@1.1.0-2</p>
+<p id="footer">commands — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/npm.html">npm(3)</a></li></ul>
</div>
-<p id="footer">config — npm@1.1.0-2</p>
+<p id="footer">config — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/publish.html">publish(3)</a></li><li><a href="../api/unpublish.html">unpublish(3)</a></li><li><a href="../doc/registry.html">registry(1)</a></li></ul>
</div>
-<p id="footer">deprecate — npm@1.1.0-2</p>
+<p id="footer">deprecate — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This command will launch a browser, so this command may not be the most
friendly for programmatic use.</p>
</div>
-<p id="footer">docs — npm@1.1.0-2</p>
+<p id="footer">docs — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Since this command opens an editor in a new process, be careful about where
and how this is used.</p>
</div>
-<p id="footer">edit — npm@1.1.0-2</p>
+<p id="footer">edit — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The first element in the 'args' parameter must be a package name. After that is the optional command, which can be any number of strings. All of the strings will be combined into one, space-delimited command.</p>
</div>
-<p id="footer">explore — npm@1.1.0-2</p>
+<p id="footer">explore — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The silent parameter is not neccessary not used, but it may in the future.</p>
</div>
-<p id="footer">help-search — npm@1.1.0-2</p>
+<p id="footer">help-search — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p><a href="../doc/json.html">json(1)</a></p>
</div>
-<p id="footer">init — npm@1.1.0-2</p>
+<p id="footer">init — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Finally, 'callback' is a function that will be called when all packages have been
installed or when an error has been encountered.</p>
</div>
-<p id="footer">install — npm@1.1.0-2</p>
+<p id="footer">install — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Now, any changes to the redis package will be reflected in
the package in the current working directory</p>
</div>
-<p id="footer">link — npm@1.1.0-2</p>
+<p id="footer">link — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>For a list of all the available command-line configs, see <code>npm help config</code></p>
</div>
-<p id="footer">load — npm@1.1.0-2</p>
+<p id="footer">load — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>If the silent parameter is set to true, nothing will be output to the screen,
but the data will still be returned.</p>
+<p>Callback is provided an error if one occurred, the full data about which
+packages are installed and which dependencies they will receive, and a
+"lite" data object which just shows which versions are installed where.
+Note that the full data object is a circular structure, so care must be
+taken if it is serialized to JSON.</p>
+
<h2 id="CONFIGURATION">CONFIGURATION</h2>
<h3 id="long">long</h3>
This means that if a submodule a same dependency as a parent module, then the
dependency will only be output once.</p>
</div>
-<p id="footer">ls — npm@1.1.0-2</p>
+<p id="footer">ls — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="VERSION">VERSION</h2>
-<p>1.1.0-2</p>
+<p>1.1.21</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<pre><code>var cmd = npm.deref("unp") // cmd === "unpublish"</code></pre>
</div>
-<p id="footer">npm — npm@1.1.0-2</p>
+<p id="footer">npm — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>If the 'packages' parameter is left out, npm will check all packages.</p>
</div>
-<p id="footer">outdated — npm@1.1.0-2</p>
+<p id="footer">outdated — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/publish.html">publish(3)</a></li><li><a href="../doc/registry.html">registry(1)</a></li></ul>
</div>
-<p id="footer">owner — npm@1.1.0-2</p>
+<p id="footer">owner — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>If no arguments are supplied, then npm packs the current package folder.</p>
</div>
-<p id="footer">pack — npm@1.1.0-2</p>
+<p id="footer">pack — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically</p>
</div>
-<p id="footer">prefix — npm@1.1.0-2</p>
+<p id="footer">prefix — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Extraneous packages are packages that are not listed on the parent
package's dependencies list.</p>
</div>
-<p id="footer">prune — npm@1.1.0-2</p>
+<p id="footer">prune — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../api/owner.html">owner(3)</a></li></ul>
</div>
-<p id="footer">publish — npm@1.1.0-2</p>
+<p id="footer">publish — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>See <code>npm help build</code></p>
</div>
-<p id="footer">rebuild — npm@1.1.0-2</p>
+<p id="footer">rebuild — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/start.html">start(3)</a></li><li><a href="../api/stop.html">stop(3)</a></li></ul>
</div>
-<p id="footer">restart — npm@1.1.0-2</p>
+<p id="footer">restart — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically.</p>
</div>
-<p id="footer">root — npm@1.1.0-2</p>
+<p id="footer">root — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../api/test.html">test(3)</a></li><li><a href="../api/start.html">start(3)</a></li><li><a href="../api/restart.html">restart(3)</a></li><li><a href="../api/stop.html">stop(3)</a></li></ul>
</div>
-<p id="footer">run-script — npm@1.1.0-2</p>
+<p id="footer">run-script — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
and doesn't try to read your mind (it doesn't do any verb tense matching or the
like).</p>
</div>
-<p id="footer">search — npm@1.1.0-2</p>
+<p id="footer">search — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Finally, 'callback' is a function that will be called when the shrinkwrap has
been saved.</p>
</div>
-<p id="footer">shrinkwrap — npm@1.1.16</p>
+<p id="footer">shrinkwrap — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>npm can run tests on multiple packages. Just specify multiple packages
in the <code>packages</code> parameter.</p>
</div>
-<p id="footer">start — npm@1.1.0-2</p>
+<p id="footer">start — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>npm can run stop on multiple packages. Just specify multiple packages
in the <code>packages</code> parameter.</p>
</div>
-<p id="footer">stop — npm@1.1.0-2</p>
+<p id="footer">stop — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li>npm help json</li><li>git help submodule</li></ul>
</div>
-<p id="footer">submodule — npm@1.1.0-2</p>
+<p id="footer">submodule — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
used. For more information about how to set this config, check
<code>man 3 npm-config</code> for programmatic usage or <code>man npm-config</code> for cli usage.</p>
</div>
-<p id="footer">tag — npm@1.1.0-2</p>
+<p id="footer">tag — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>npm can run tests on multiple packages. Just specify multiple packages
in the <code>packages</code> parameter.</p>
</div>
-<p id="footer">test — npm@1.1.0-2</p>
+<p id="footer">test — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Finally, 'callback' is a function that will be called when all packages have been
uninstalled or when an error has been encountered.</p>
</div>
-<p id="footer">uninstall — npm@1.1.0-2</p>
+<p id="footer">uninstall — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>If no version is specified, or if all versions are removed then
the root package entry is removed from the registry entirely.</p>
</div>
-<p id="footer">unpublish — npm@1.1.0-2</p>
+<p id="footer">unpublish — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The 'packages' argument is an array of packages to update. The 'callback' parameter will be called when done or when an error occurs.</p>
</div>
-<p id="footer">update — npm@1.1.0-2</p>
+<p id="footer">update — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
parameter. The difference, however, is this function will fail if it does
not have exactly one element. The only element should be a version number.</p>
</div>
-<p id="footer">version — npm@1.1.0-2</p>
+<p id="footer">version — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>corresponding to the list of fields selected.</p>
</div>
-<p id="footer">view — npm@1.1.0-2</p>
+<p id="footer">view — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically</p>
</div>
-<p id="footer">whoami — npm@1.1.0-2</p>
+<p id="footer">whoami — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/help.html">help(1)</a></li><li><a href="../doc/index.html">index(1)</a></li></ul>
</div>
-<p id="footer"><a href="../doc/README.html">README</a> — npm@1.1.0-2</p>
+<p id="footer"><a href="../doc/README.html">README</a> — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/owner.html">owner(1)</a></li><li><a href="../doc/whoami.html">whoami(1)</a></li></ul>
</div>
-<p id="footer">adduser — npm@1.1.0-2</p>
+<p id="footer">adduser — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/prefix.html">prefix(1)</a></li><li><a href="../doc/root.html">root(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">bin — npm@1.1.0-2</p>
+<p id="footer">bin — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/docs.html">docs(1)</a></li><li><a href="../doc/view.html">view(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/json.html">json(1)</a></li></ul>
</div>
-<p id="footer">bugs — npm@1.1.0-2</p>
+<p id="footer">bugs — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/link.html">link(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/json.html">json(1)</a></li></ul>
</div>
-<p id="footer">build — npm@1.1.0-2</p>
+<p id="footer">build — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/install.html">install(1)</a></li></ul>
</div>
-<p id="footer">bundle — npm@1.1.0-2</p>
+<p id="footer">bundle — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/pack.html">pack(1)</a></li></ul>
</div>
-<p id="footer">cache — npm@1.1.0-2</p>
+<p id="footer">cache — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="HISTORY">HISTORY</h2>
+<h3 id="1-1-3-1-1-4">1.1.3, 1.1.4</h3>
+
+<ul><li>Update request to support HTTPS-over-HTTP proxy tunneling</li><li>Throw on undefined envs in config settings</li><li>Update which to 1.0.5</li><li>Fix windows UNC busyloop in findPrefix</li><li>Bundle nested bundleDependencies properly</li><li>Alias adduser to add-user</li><li>Doc updates (Christian Howe, Henrik Hodne, Andrew Lunny)</li><li>ignore logfd/outfd streams in makeEnv() (Rod Vagg)</li><li>shrinkwrap: Behave properly with url-installed deps</li><li>install: Support --save with url install targets</li><li>Support installing naked tars or single-file modules from urls etc.</li><li>init: Don't add engines section</li><li>Don't run make clean on rebuild</li><li>Added missing unicode replacement (atomizer)</li></ul>
+
+<h3 id="1-1-2">1.1.2</h3>
+
+<p>Dave Pacheco (2):
+ add "npm shrinkwrap"</p>
+
+<p>Martin Cooper (1):
+ Fix #1753 Make a copy of the cached objects we'll modify.</p>
+
+<p>Tim Oxley (1):
+ correctly remove readme from default npm view command.</p>
+
+<p>Tyler Green (1):
+ fix #2187 set terminal columns to Infinity if 0</p>
+
+<p>isaacs (19):
+ update minimatch
+ update request
+ Experimental: single-file modules
+ Fix #2172 Don't remove global mans uninstalling local pkgs
+ Add --versions flag to show the version of node as well
+ Support --json flag for ls output
+ update request to 2.9.151</p>
+
+<h3 id="1-1">1.1</h3>
+
+<ul><li>Replace system tar dependency with a JS tar</li><li>Continue to refine</li></ul>
+
<h3 id="1-0">1.0</h3>
<ul><li>Greatly simplified folder structure </li><li>Install locally (bundle by default) </li><li>Drastic rearchitecture</li></ul>
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li></ul>
</div>
-<p id="footer">changelog — npm@1.1.0-2</p>
+<p id="footer">changelog — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Don't use them except in four situations:</p>
<ul><li><code>for (;;)</code> loops. They're actually required.</li><li>null loops like: <code>while (something) ;</code> (But you'd better have a good
-reason for doing that.)</li><li>case "foo": doSomething(); break</li><li>In front of a leading ( or [ at the start of the line.
+reason for doing that.)</li><li><code>case "foo": doSomething(); break</code></li><li>In front of a leading <code>(</code> or <code>[</code> at the start of the line.
This prevents the expression from being interpreted
as a function call or property access, respectively.</li></ul>
<ul><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">coding-style — npm@1.1.0-2</p>
+<p id="footer">coding-style — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">completion — npm@1.1.0-2</p>
+<p id="footer">completion — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The following shorthands are parsed on the command-line:</p>
-<ul><li><code>-v</code>: <code>--version</code></li><li><code>-h</code>, <code>-?</code>, <code>--help</code>, <code>-H</code>: <code>--usage</code></li><li><code>-s</code>, <code>--silent</code>: <code>--loglevel silent</code></li><li><code>-q</code>, <code>--quiet</code>: <code>--loglevel warn</code></li><li><code>-d</code>: <code>--loglevel info</code></li><li><code>-dd</code>, <code>--verbose</code>: <code>--loglevel verbose</code></li><li><code>-ddd</code>: <code>--loglevel silly</code></li><li><code>-g</code>: <code>--global</code></li><li><code>-l</code>: <code>--long</code></li><li><code>-m</code>: <code>--message</code></li><li><code>-p</code>, <code>--porcelain</code>: <code>--parseable</code></li><li><code>-reg</code>: <code>--registry</code></li><li><code>-v</code>: <code>--version</code></li><li><code>-f</code>: <code>--force</code></li><li><code>-l</code>: <code>--long</code></li><li><code>-desc</code>: <code>--description</code></li><li><code>-S</code>: <code>--save</code></li><li><code>-y</code>: <code>--yes</code></li><li><code>-n</code>: <code>--yes false</code></li><li><code>ll</code> and <code>la</code> commands: <code>ls --long</code></li></ul>
+<ul><li><code>-v</code>: <code>--version</code></li><li><code>-h</code>, <code>-?</code>, <code>--help</code>, <code>-H</code>: <code>--usage</code></li><li><code>-s</code>, <code>--silent</code>: <code>--loglevel silent</code></li><li><code>-q</code>, <code>--quiet</code>: <code>--loglevel warn</code></li><li><code>-d</code>: <code>--loglevel info</code></li><li><code>-dd</code>, <code>--verbose</code>: <code>--loglevel verbose</code></li><li><code>-ddd</code>: <code>--loglevel silly</code></li><li><code>-g</code>: <code>--global</code></li><li><code>-l</code>: <code>--long</code></li><li><code>-m</code>: <code>--message</code></li><li><code>-p</code>, <code>--porcelain</code>: <code>--parseable</code></li><li><code>-reg</code>: <code>--registry</code></li><li><code>-v</code>: <code>--version</code></li><li><code>-f</code>: <code>--force</code></li><li><code>-l</code>: <code>--long</code></li><li><code>-desc</code>: <code>--description</code></li><li><code>-S</code>: <code>--save</code></li><li><code>-D</code>: <code>--save-dev</code></li><li><code>-O</code>: <code>--save-optional</code></li><li><code>-y</code>: <code>--yes</code></li><li><code>-n</code>: <code>--yes false</code></li><li><code>ll</code> and <code>la</code> commands: <code>ls --long</code></li></ul>
<p>If the specified configuration param resolves unambiguously to a known
configuration parameter, then it is expanded to that configuration
<p>The location of npm's cache directory. See <code><a href="../doc/cache.html">cache(1)</a></code></p>
+<h3 id="cache-max">cache-max</h3>
+
+<ul><li>Default: Infinity</li><li>Type: Number</li></ul>
+
+<p>The maximum time (in seconds) to keep items in the registry cache before
+re-checking against the registry.</p>
+
+<p>Note that no purging is done unless the <code>npm cache clean</code> command is
+explicitly used, and that only GET requests use the cache.</p>
+
+<h3 id="cache-min">cache-min</h3>
+
+<ul><li>Default: 0</li><li>Type: Number</li></ul>
+
+<p>The minimum time (in seconds) to keep items in the registry cache before
+re-checking against the registry.</p>
+
+<p>Note that no purging is done unless the <code>npm cache clean</code> command is
+explicitly used, and that only GET requests use the cache.</p>
+
<h3 id="color">color</h3>
<ul><li>Default: true on Posix, false on Windows</li><li>Type: Boolean or <code>"always"</code></li></ul>
<p>A proxy to use for outgoing https requests.</p>
+<h3 id="user-agent">user-agent</h3>
+
+<ul><li>Default: npm/{npm.version} node/{process.version}</li><li>Type: String</li></ul>
+
+<p>Sets a User-Agent to the request header</p>
+
<h3 id="ignore">ignore</h3>
<ul><li>Default: ""</li><li>Type: string</li></ul>
<h3 id="init-author-name">init.author.name</h3>
-<ul><li>Default: "0.0.0"</li><li>Type: String</li></ul>
+<ul><li>Default: ""</li><li>Type: String</li></ul>
<p>The value <code>npm init</code> should use by default for the package author's name.</p>
<p>The value <code>npm init</code> should use by default for the package author's homepage.</p>
+<h3 id="json">json</h3>
+
+<ul><li>Default: false</li><li>Type: Boolean</li></ul>
+
+<p>Whether or not to output JSON data, rather than the normal output.</p>
+
+<p>This feature is currently experimental, and the output data structures
+for many commands is either not implemented in JSON yet, or subject to
+change. Only the output from <code>npm ls --json</code> is currently valid.</p>
+
<h3 id="link">link</h3>
<ul><li>Default: false</li><li>Type: Boolean</li></ul>
<p>Only works if there is already a package.json file present.</p>
+<h3 id="save-dev">save-dev</h3>
+
+<ul><li>Default: false</li><li>Type: Boolean</li></ul>
+
+<p>Save installed packages to a package.json file as devDependencies.</p>
+
+<p>Only works if there is already a package.json file present.</p>
+
+<h3 id="save-optional">save-optional</h3>
+
+<ul><li>Default: false</li><li>Type: Boolean</li></ul>
+
+<p>Save installed packages to a package.json file as optionalDependencies.</p>
+
+<p>Only works if there is already a package.json file present.</p>
+
<h3 id="searchopts">searchopts</h3>
<ul><li>Default: ""</li><li>Type: String</li></ul>
<p>Only relevant when specified explicitly on the command line.</p>
+<h3 id="versions">versions</h3>
+
+<ul><li>Default: false</li><li>Type: boolean</li></ul>
+
+<p>If true, output the npm version as well as node's <code>process.versions</code>
+hash, and exit successfully.</p>
+
+<p>Only relevant when specified explicitly on the command line.</p>
+
<h3 id="viewer">viewer</h3>
<ul><li>Default: "man" on Posix, "browser" on Windows</li><li>Type: path</li></ul>
<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">config — npm@1.1.0-2</p>
+<p id="footer">config — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li></ul>
</div>
-<p id="footer">deprecate — npm@1.1.0-2</p>
+<p id="footer">deprecate — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>A package is:</p>
-<ul><li>a) a folder containing a program described by a package.json file</li><li>b) a gzipped tarball containing (a)</li><li>c) a url that resolves to (b)</li><li>d) a <code><name>@<version></code> that is published on the registry with (c)</li><li>e) a <code><name>@<tag></code> that points to (d)</li><li>f) a <code><name></code> that has a "latest" tag satisfying (e)</li></ul>
+<ul><li>a) a folder containing a program described by a package.json file</li><li>b) a gzipped tarball containing (a)</li><li>c) a url that resolves to (b)</li><li>d) a <code><name>@<version></code> that is published on the registry with (c)</li><li>e) a <code><name>@<tag></code> that points to (d)</li><li>f) a <code><name></code> that has a "latest" tag satisfying (e)</li><li>g) a <code>git</code> url that, when cloned, results in (a).</li></ul>
<p>Even if you never publish your package, you can still get a lot of
benefits of using npm if you just want to write a node program (a), and
perhaps if you also want to be able to easily install it elsewhere
after packing it up into a tarball (b).</p>
+<p>Git urls can be of the form:</p>
+
+<pre><code>git://github.com/user/project.git#commit-ish
+git+ssh://user@hostname:project.git#commit-ish
+git+http://user@hostname/project/blah.git#commit-ish
+git+https://user@hostname/project/blah.git#commit-ish</code></pre>
+
+<p>The <code>commit-ish</code> can be any tag, sha, or branch which can be supplied as
+an argument to <code>git checkout</code>. The default is <code>master</code>.</p>
+
<h2 id="The-package-json-File">The package.json File</h2>
<p>You need to have a <code>package.json</code> file in the root of your project to do
<ul><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/init.html">init(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li></ul>
</div>
-<p id="footer">developers — npm@1.1.0-2</p>
+<p id="footer">developers — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/owner.html">owner(1)</a></li></ul>
</div>
-<p id="footer">disputes — npm@1.1.0-2</p>
+<p id="footer">disputes — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/view.html">view(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/json.html">json(1)</a></li></ul>
</div>
-<p id="footer">docs — npm@1.1.0-2</p>
+<p id="footer">docs — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/explore.html">explore(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">edit — npm@1.1.0-2</p>
+<p id="footer">edit — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/submodule.html">submodule(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/edit.html">edit(1)</a></li><li><a href="../doc/rebuild.html">rebuild(1)</a></li><li><a href="../doc/build.html">build(1)</a></li><li><a href="../doc/install.html">install(1)</a></li></ul>
</div>
-<p id="footer">explore — npm@1.1.0-2</p>
+<p id="footer">explore — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li></ul>
</div>
-<p id="footer">faq — npm@1.1.0-2</p>
+<p id="footer">faq — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/pack.html">pack(1)</a></li><li><a href="../doc/cache.html">cache(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li></ul>
</div>
-<p id="footer">folders — npm@1.1.0-2</p>
+<p id="footer">folders — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/help.html">help(1)</a></li></ul>
</div>
-<p id="footer">help-search — npm@1.1.0-2</p>
+<p id="footer">help-search — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/README.html">README</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/help-search.html">help-search(1)</a></li><li><a href="../doc/index.html">index(1)</a></li></ul>
</div>
-<p id="footer">help — npm@1.1.0-2</p>
+<p id="footer">help — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p> The semantic versioner for npm</p>
+<h2 id="npm-shrinkwrap-1"><a href="../doc/shrinkwrap.html">shrinkwrap(1)</a></h2>
+
+<p> Lock down dependency versions</p>
+
<h2 id="npm-star-1"><a href="../doc/star.html">star(1)</a></h2>
<p> Mark your favorite packages</p>
<p> Search for packages</p>
+<h2 id="npm-shrinkwrap-3"><a href="../api/shrinkwrap.html">shrinkwrap(3)</a></h2>
+
+<p> programmatically generate package shrinkwrap file</p>
+
<h2 id="npm-start-3"><a href="../api/start.html">start(3)</a></h2>
<p> Start a package</p>
<p> Display npm username</p>
</div>
-<p id="footer">index — npm@1.1.0-2</p>
+<p id="footer">index — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/version.html">version(1)</a></li></ul>
</div>
-<p id="footer">init — npm@1.1.0-2</p>
+<p id="footer">init — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
npm install <tarball file>
npm install <tarball url>
npm install <folder>
-npm install <name>
+npm install <name> [--save|--save-dev|--save-optional]
npm install <name>@<tag>
npm install <name>@<version>
+npm install <name>@<version range>
npm install <name>@<version range></code></pre>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
-<p>This command installs a package, and any packages that it depends on.</p>
+<p>This command installs a package, and any packages that it depends on. If the
+package has a shrinkwrap file, the installation of dependencies will be driven
+by that. See <a href="../doc/shrinkwrap.html">shrinkwrap(1)</a>.</p>
<p>A <code>package</code> is:</p>
perhaps if you also want to be able to easily install it elsewhere
after packing it up into a tarball (b).</p>
-<ul><li><p><code>npm install</code> (in package directory, no arguments):
-Install the dependencies in the local node_modules folder.</p><p>In global mode (ie, with <code>-g</code> or <code>--global</code> appended to the command),
+<ul><li><p><code>npm install</code> (in package directory, no arguments):</p><p>Install the dependencies in the local node_modules folder.</p><p>In global mode (ie, with <code>-g</code> or <code>--global</code> appended to the command),
it installs the current package context (ie, the current working
-directory) as a global package.</p></li><li><p><code>npm install <folder></code>:
-Install a package that is sitting in a folder on the filesystem.</p></li><li><p><code>npm install <tarball file></code>:
-Install a package that is sitting on the filesystem. Note: if you just want
+directory) as a global package.</p></li><li><p><code>npm install <folder></code>:</p><p>Install a package that is sitting in a folder on the filesystem.</p></li><li><p><code>npm install <tarball file></code>:</p><p>Install a package that is sitting on the filesystem. Note: if you just want
to link a dev directory into your npm root, you can do this more easily by
-using <code>npm link</code>.</p><p>Example:</p><pre><code>npm install ./package.tgz</code></pre></li><li><p><code>npm install <tarball url></code>:
-Fetch the tarball url, and then install it. In order to distinguish between
-this and other options, the argument must start with "http://" or "https://"</p><p>Example:</p><pre><code>npm install https://github.com/indexzero/forever/tarball/v0.5.6</code></pre></li><li><p><code>npm install <name></code>:
-Do a <code><name>@<tag></code> install, where <code><tag></code> is the "tag" config. (See
-<code><a href="../doc/config.html">config(1)</a></code>)</p><p>Example:</p><pre><code>npm install sax</code></pre><p><strong>Note</strong>: If there is a file or folder named <code><name></code> in the current
+using <code>npm link</code>.</p><p>Example:</p><pre><code> npm install ./package.tgz</code></pre></li><li><p><code>npm install <tarball url></code>:</p><p>Fetch the tarball url, and then install it. In order to distinguish between
+this and other options, the argument must start with "http://" or "https://"</p><p>Example:</p><pre><code> npm install https://github.com/indexzero/forever/tarball/v0.5.6</code></pre></li><li><p><code>npm install <name> [--save|--save-dev|--save-optional]</code>:</p><p>Do a <code><name>@<tag></code> install, where <code><tag></code> is the "tag" config. (See
+<code><a href="../doc/config.html">config(1)</a></code>.)</p><p>In most cases, this will install the latest version
+of the module published on npm.</p><p>Example:</p><p> npm install sax</p><p><code>npm install</code> takes 3 exclusive, optional flags which save or update
+the package version in your main package.json:</p><ul><li><p><code>--save</code>: Package will appear in your <code>dependencies</code>.</p></li><li><p><code>--save-dev</code>: Package will appear in your <code>devDependencies</code>.</p></li><li><p><code>--save-optional</code>: Package will appear in your <code>optionalDependencies</code>.</p><p>Examples:</p><p> npm install sax --save
+ npm install node-tap --save-dev
+ npm install dtrace-provider --save-optional</p><p><strong>Note</strong>: If there is a file or folder named <code><name></code> in the current
working directory, then it will try to install that, and only try to
-fetch the package by name if it is not valid.</p></li><li><p><code>npm install <name>@<tag></code>:
-Install the version of the package that is referenced by the specified tag.
+fetch the package by name if it is not valid.</p></li></ul></li><li><p><code>npm install <name>@<tag></code>:</p><p>Install the version of the package that is referenced by the specified tag.
If the tag does not exist in the registry data for that package, then this
-will fail.</p><p>Example:</p><pre><code>npm install sax@latest</code></pre></li><li><p><code>npm install <name>@<version></code>:
-Install the specified version of the package. This will fail if the version
-has not been published to the registry.</p><p>Example:</p><pre><code>npm install sax@0.1.1</code></pre></li><li><p><code>npm install <name>@<version range></code>:
-Install a version of the package matching the specified version range. This
+will fail.</p><p>Example:</p><pre><code> npm install sax@latest</code></pre></li><li><p><code>npm install <name>@<version></code>:</p><p>Install the specified version of the package. This will fail if the version
+has not been published to the registry.</p><p>Example:</p><pre><code> npm install sax@0.1.1</code></pre></li><li><p><code>npm install <name>@<version range></code>:</p><p>Install a version of the package matching the specified version range. This
will follow the same rules for resolving dependencies described in <code><a href="../doc/json.html">json(1)</a></code>.</p><p>Note that most version ranges must be put in quotes so that your shell will
-treat it as a single argument.</p><p>Example:</p><pre><code>npm install sax@">=0.1.0 <0.2.0"</code></pre></li><li><p><code>npm install <git remote url></code>:</p><p>Install a package by cloning a git remote url. The format of the git
-url is:</p><pre><code><protocol>://[<user>@]<hostname><separator><path>[#<commit-ish>]</code></pre><p><code><protocol></code> is one of <code>git</code>, <code>git+ssh</code>, <code>git+http</code>, or
+treat it as a single argument.</p><p>Example:</p><p> npm install sax@">=0.1.0 <0.2.0"</p></li><li><p><code>npm install <git remote url></code>:</p><p>Install a package by cloning a git remote url. The format of the git
+url is:</p><p> <protocol>://[<user>@]<hostname><separator><path>[#<commit-ish>]</p><p><code><protocol></code> is one of <code>git</code>, <code>git+ssh</code>, <code>git+http</code>, or
<code>git+https</code>. If no <code><commit-ish></code> is specified, then <code>master</code> is
-used.</p><p>Examples:</p><pre><code>git+ssh://git@github.com:isaacs/npm.git#v1.0.27
-git+https://isaacs@github.com/isaacs/npm.git
-git://github.com/isaacs/npm.git#v1.0.27</code></pre></li></ul>
+used.</p><p>Examples:</p><pre><code> git+ssh://git@github.com:isaacs/npm.git#v1.0.27
+ git+https://isaacs@github.com/isaacs/npm.git
+ git://github.com/isaacs/npm.git#v1.0.27</code></pre></li></ul>
<p>You may combine multiple arguments, and even multiple types of arguments.
For example:</p>
<h2 id="SEE-ALSO">SEE ALSO</h2>
-<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/update.html">update(1)</a></li><li><a href="../doc/link.html">link(1)</a></li><li><a href="../doc/rebuild.html">rebuild(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/build.html">build(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/tag.html">tag(1)</a></li><li><a href="../doc/rm.html">rm(1)</a></li></ul>
+<ul><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/update.html">update(1)</a></li><li><a href="../doc/link.html">link(1)</a></li><li><a href="../doc/rebuild.html">rebuild(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/build.html">build(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/tag.html">tag(1)</a></li><li><a href="../doc/rm.html">rm(1)</a></li><li><a href="../doc/shrinkwrap.html">shrinkwrap(1)</a></li></ul>
</div>
-<p id="footer">install — npm@1.1.0-2</p>
+<p id="footer">install — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>Version range descriptors may be any of the following styles, where "version"
is a semver compatible version identifier.</p>
-<ul><li><code>version</code> Must match <code>version</code> exactly</li><li><code>=version</code> Same as just <code>version</code></li><li><code>>version</code> Must be greater than <code>version</code></li><li><code>>=version</code> etc</li><li><code><version</code></li><li><code><=version</code></li><li><code>~version</code> See 'Tilde Version Ranges' below</li><li><code>1.2.x</code> See 'X Version Ranges' below</li><li><code>http://...</code> See 'URLs as Dependencies' below</li><li><code>*</code> Matches any version</li><li><code>""</code> (just an empty string) Same as <code>*</code></li><li><code>version1 - version2</code> Same as <code>>=version1 <=version2</code>.</li><li><code>range1 || range2</code> Passes if either range1 or range2 are satisfied.</li></ul>
+<ul><li><code>version</code> Must match <code>version</code> exactly</li><li><code>=version</code> Same as just <code>version</code></li><li><code>>version</code> Must be greater than <code>version</code></li><li><code>>=version</code> etc</li><li><code><version</code></li><li><code><=version</code></li><li><code>~version</code> See 'Tilde Version Ranges' below</li><li><code>1.2.x</code> See 'X Version Ranges' below</li><li><code>http://...</code> See 'URLs as Dependencies' below</li><li><code>*</code> Matches any version</li><li><code>""</code> (just an empty string) Same as <code>*</code></li><li><code>version1 - version2</code> Same as <code>>=version1 <=version2</code>.</li><li><code>range1 || range2</code> Passes if either range1 or range2 are satisfied.</li><li><code>git...</code> See 'Git URLs as Dependencies' below</li></ul>
<p>For example, these are all valid:</p>
<p>This tarball will be downloaded and installed locally to your package at
install time.</p>
+<h3 id="Git-URLs-as-Dependencies">Git URLs as Dependencies</h3>
+
+<p>Git urls can be of the form:</p>
+
+<pre><code>git://github.com/user/project.git#commit-ish
+git+ssh://user@hostname:project.git#commit-ish
+git+http://user@hostname/project/blah.git#commit-ish
+git+https://user@hostname/project/blah.git#commit-ish</code></pre>
+
+<p>The <code>commit-ish</code> can be any tag, sha, or branch which can be supplied as
+an argument to <code>git checkout</code>. The default is <code>master</code>.</p>
+
<h2 id="devDependencies">devDependencies</h2>
<p>If someone is planning on downloading and using your module in their
<pre><code>{ "engines" : { "npm" : "~1.0.20" } }</code></pre>
+<h2 id="os">os</h2>
+
+<p>You can specify which operating systems your
+module will run on:</p>
+
+<pre><code>"os" : [ "darwin", "linux" ]</code></pre>
+
+<p>You can also blacklist instead of whitelist operating systems,
+just prepend the blacklisted os with a '!':</p>
+
+<pre><code>"os" : [ "!win32" ]</code></pre>
+
+<p>The host operating system is determined by <code>process.platform</code></p>
+
+<p>It is allowed to both blacklist, and whitelist, although there isn't any
+good reason to do this.</p>
+
+<h2 id="cpu">cpu</h2>
+
+<p>If your code only runs on certain cpu architectures,
+you can specify which ones.</p>
+
+<pre><code>"cpu" : [ "x64", "ia32" ]</code></pre>
+
+<p>Like the <code>os</code> option, you can also blacklist architectures:</p>
+
+<pre><code>"cpu" : [ "!arm", "!mips" ]</code></pre>
+
+<p>The host architecture is determined by <code>process.arch</code></p>
+
<h2 id="preferGlobal">preferGlobal</h2>
<p>If your package is primarily a command-line application that should be
<p>This is a way to prevent accidental publication of private repositories.
If you would like to ensure that a given package is only ever published
-to a speciic registry (for example, an internal registry),
+to a specific registry (for example, an internal registry),
then use the <code>publishConfig</code> hash described below
to override the <code>registry</code> config param at publish-time.</p>
<ul><li><a href="../doc/semver.html">semver(1)</a></li><li><a href="../doc/init.html">init(1)</a></li><li><a href="../doc/version.html">version(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/help.html">help(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/rm.html">rm(1)</a></li></ul>
</div>
-<p id="footer">json — npm@1.1.0-2</p>
+<p id="footer">json — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">link — npm@1.1.0-2</p>
+<p id="footer">link — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="CONFIGURATION">CONFIGURATION</h2>
+<h3 id="json">json</h3>
+
+<ul><li>Default: false</li><li>Type: Boolean</li></ul>
+
+<p>Show information in JSON format.</p>
+
<h3 id="long">long</h3>
<ul><li>Default: false</li><li>Type: Boolean</li></ul>
<ul><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/link.html">link(1)</a></li><li><a href="../doc/prune.html">prune(1)</a></li><li><a href="../doc/outdated.html">outdated(1)</a></li><li><a href="../doc/update.html">update(1)</a></li></ul>
</div>
-<p id="footer">list — npm@1.1.0-2</p>
+<p id="footer">list — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="VERSION">VERSION</h2>
-<p>1.1.0-2</p>
+<p>1.1.21</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<ul><li><a href="../doc/help.html">help(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/README.html">README</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/index.html">index(1)</a></li><li><a href="../api/npm.html">npm(3)</a></li></ul>
</div>
-<p id="footer">npm — npm@1.1.0-2</p>
+<p id="footer">npm — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/update.html">update(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li></ul>
</div>
-<p id="footer">outdated — npm@1.1.0-2</p>
+<p id="footer">outdated — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../doc/disputes.html">disputes(1)</a></li></ul>
</div>
-<p id="footer">owner — npm@1.1.0-2</p>
+<p id="footer">owner — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/cache.html">cache(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">pack — npm@1.1.0-2</p>
+<p id="footer">pack — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/root.html">root(1)</a></li><li><a href="../doc/bin.html">bin(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">prefix — npm@1.1.0-2</p>
+<p id="footer">prefix — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/rm.html">rm(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/list.html">list(1)</a></li></ul>
</div>
-<p id="footer">prune — npm@1.1.0-2</p>
+<p id="footer">prune — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../doc/owner.html">owner(1)</a></li><li><a href="../doc/deprecate.html">deprecate(1)</a></li><li><a href="../doc/tag.html">tag(1)</a></li></ul>
</div>
-<p id="footer">publish — npm@1.1.0-2</p>
+<p id="footer">publish — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/build.html">build(1)</a></li><li><a href="../doc/install.html">install(1)</a></li></ul>
</div>
-<p id="footer">rebuild — npm@1.1.0-2</p>
+<p id="footer">rebuild — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/disputes.html">disputes(1)</a></li></ul>
</div>
-<p id="footer">registry — npm@1.1.0-2</p>
+<p id="footer">registry — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/README.html">README</a></li><li><a href="../doc/rm.html">rm(1)</a></li><li><a href="../doc/prune.html">prune(1)</a></li></ul>
</div>
-<p id="footer">removing-npm — npm@1.1.0-2</p>
+<p id="footer">removing-npm — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/test.html">test(1)</a></li><li><a href="../doc/start.html">start(1)</a></li><li><a href="../doc/stop.html">stop(1)</a></li></ul>
</div>
-<p id="footer">restart — npm@1.1.0-2</p>
+<p id="footer">restart — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/prefix.html">prefix(1)</a></li><li><a href="../doc/bin.html">bin(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">root — npm@1.1.0-2</p>
+<p id="footer">root — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/test.html">test(1)</a></li><li><a href="../doc/start.html">start(1)</a></li><li><a href="../doc/restart.html">restart(1)</a></li><li><a href="../doc/stop.html">stop(1)</a></li></ul>
</div>
-<p id="footer">run-script — npm@1.1.0-2</p>
+<p id="footer">run-script — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
made available regarding the setup of npm and the current state of the
process.</p>
+<h3 id="path">path</h3>
+
+<p>If you depend on modules that define executable scripts, like test suites,
+then those executables will be added to the <code>PATH</code> for executing the scripts.
+So, if your package.json has this:</p>
+
+<pre><code>{ "name" : "foo"
+, "dependencies" : { "bar" : "0.1.x" }
+, "scripts": { "start" : "bar ./test" } }</code></pre>
+
+<p>then you could run <code>npm start</code> to execute the <code>bar</code> script, which is exported
+into the <code>node_modules/.bin</code> directory on <code>npm install</code>.</p>
+
<h3 id="package-json-vars">package.json vars</h3>
<p>The package.json fields are tacked onto the <code>npm_package_</code> prefix. So, for
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/developers.html">developers(1)</a></li><li><a href="../doc/install.html">install(1)</a></li></ul>
</div>
-<p id="footer">scripts — npm@1.1.0-2</p>
+<p id="footer">scripts — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/view.html">view(1)</a></li></ul>
</div>
-<p id="footer">search — npm@1.1.0-2</p>
+<p id="footer">search — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/json.html">json(1)</a></li></ul>
</div>
-<p id="footer">semver — npm@1.1.0-2</p>
+<p id="footer">semver — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/list.html">list(1)</a></li></ul>
</div>
-<p id="footer">shrinkwrap — npm@1.1.16</p>
+<p id="footer">shrinkwrap — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/view.html">view(1)</a></li><li><a href="../doc/whoami.html">whoami(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li></ul>
</div>
-<p id="footer">star — npm@1.1.0-2</p>
+<p id="footer">star — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/test.html">test(1)</a></li><li><a href="../doc/restart.html">restart(1)</a></li><li><a href="../doc/stop.html">stop(1)</a></li></ul>
</div>
-<p id="footer">start — npm@1.1.0-2</p>
+<p id="footer">start — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/test.html">test(1)</a></li><li><a href="../doc/start.html">start(1)</a></li><li><a href="../doc/restart.html">restart(1)</a></li></ul>
</div>
-<p id="footer">stop — npm@1.1.0-2</p>
+<p id="footer">stop — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/json.html">json(1)</a></li><li>git help submodule</li></ul>
</div>
-<p id="footer">submodule — npm@1.1.0-2</p>
+<p id="footer">submodule — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">tag — npm@1.1.0-2</p>
+<p id="footer">tag — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/run-script.html">run-script(1)</a></li><li><a href="../doc/scripts.html">scripts(1)</a></li><li><a href="../doc/start.html">start(1)</a></li><li><a href="../doc/restart.html">restart(1)</a></li><li><a href="../doc/stop.html">stop(1)</a></li></ul>
</div>
-<p id="footer">test — npm@1.1.0-2</p>
+<p id="footer">test — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/prune.html">prune(1)</a></li><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/config.html">config(1)</a></li></ul>
</div>
-<p id="footer">uninstall — npm@1.1.0-2</p>
+<p id="footer">uninstall — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/deprecate.html">deprecate(1)</a></li><li><a href="../doc/publish.html">publish(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li><li><a href="../doc/owner.html">owner(1)</a></li></ul>
</div>
-<p id="footer">unpublish — npm@1.1.0-2</p>
+<p id="footer">unpublish — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/install.html">install(1)</a></li><li><a href="../doc/outdated.html">outdated(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/folders.html">folders(1)</a></li><li><a href="../doc/list.html">list(1)</a></li></ul>
</div>
-<p id="footer">update — npm@1.1.0-2</p>
+<p id="footer">update — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/init.html">init(1)</a></li><li><a href="../doc/json.html">json(1)</a></li><li><a href="../doc/semver.html">semver(1)</a></li></ul>
</div>
-<p id="footer">version — npm@1.1.0-2</p>
+<p id="footer">version — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/search.html">search(1)</a></li><li><a href="../doc/registry.html">registry(1)</a></li><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/docs.html">docs(1)</a></li></ul>
</div>
-<p id="footer">view — npm@1.1.0-2</p>
+<p id="footer">view — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../doc/config.html">config(1)</a></li><li><a href="../doc/adduser.html">adduser(1)</a></li></ul>
</div>
-<p id="footer">whoami — npm@1.1.0-2</p>
+<p id="footer">whoami — npm@1.1.21</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>npm is a package manager for <a href="http://nodejs.org/">node</a>. You can use it to install
and publish your node programs. It manages dependencies and does other cool stuff.</p>
-<h2>One Line Install</h2>
+<h2>Easy Zero Line Install</h2>
-<code>curl http://npmjs.org/install.sh | sh</code>
+<p><a href="http://nodejs.org/#download">Install Node.js</a> <br>
+(npm comes with it.)</p>
-<h2>More Than One Line Install</h2>
+<p>Because a one-line install is one too many.</p>
+
+<h2>Fancy Install</h2>
<ol>
<li><a href="https://github.com/isaacs/npm">Get the code.</a>
says to do.
</ol>
+<p>There's a pretty thorough install script at
+<a href="http://npmjs.org/install.sh">http://npmjs.org/install.sh</a></p>
+
+<p>For maximum security, make sure to thorougly inspect every
+program that you run on your computer!</p>
+
<h2>Other Cool Stuff</h2>
<ul>
}
if (repo) {
if (Array.isArray(repo)) repo = repo.shift()
- if (repo.url) repo = repo.url
+ if (repo.hasOwnProperty("url")) repo = repo.url
log.verbose(repo, "repository")
if (repo && repo.match(/^(https?:\/\/|git(:\/\/|@))github.com/)) {
return open(repo.replace(/^git(@|:\/\/)/, "http://")
/*
adding a folder:
1. tar into tmp/random/package.tgz
-2. untar into tmp/random/contents/{blah}
-3. rename {blah} to "package"
-4. tar tmp/random/contents/package to cache/n/v/package.tgz
-5. untar cache/n/v/package.tgz into cache/n/v/package
-6. rm tmp/random
+2. untar into tmp/random/contents/package, stripping one dir piece
+3. tar tmp/random/contents/package to cache/n/v/package.tgz
+4. untar cache/n/v/package.tgz into cache/n/v/package
+5. rm tmp/random
Adding a url:
1. fetch to tmp/random/package.tgz
exports.clean = clean
exports.unpack = unpack
-var mkdir = require("./utils/mkdir-p.js")
+var mkdir = require("mkdirp")
, exec = require("./utils/exec.js")
, fetch = require("./utils/fetch.js")
, npm = require("./npm.js")
, tar = require("./utils/tar.js")
, fileCompletion = require("./utils/completion/file-completion.js")
, url = require("url")
+ , chownr = require("chownr")
cache.usage = "npm cache add <tarball file>"
+ "\nnpm cache add <folder>"
// if the pkg and ver are in the cache, then
// just do a readJson and return.
// if they're not, then fetch them from the registry.
-var cacheSeen = {}
function read (name, ver, forceBypass, cb) {
if (typeof cb !== "function") cb = forceBypass, forceBypass = true
var jsonFile = path.join(npm.cache, name, ver, "package", "package.json")
function c (er, data) {
- if (!er) cacheSeen[data._id] = data
if (data) deprCheck(data)
return cb(er, data)
}
return addNamed(name, ver, c)
}
- if (name+"@"+ver in cacheSeen) {
- return cb(null, cacheSeen[name+"@"+ver])
- }
-
readJson(jsonFile, function (er, data) {
if (er) return addNamed(name, ver, c)
deprCheck(data)
output = output || require("./utils/output.js")
args = args.join("/").split("@").join("/")
if (args.substr(-1) === "/") args = args.substr(0, args.length - 1)
+ var prefix = npm.config.get("cache")
+ if (0 === prefix.indexOf(process.env.HOME)) {
+ prefix = "~" + prefix.substr(process.env.HOME.length)
+ }
ls_(args, npm.config.get("depth"), function(er, files) {
output.write(files.map(function (f) {
- return path.join("~/.npm", f)
+ return path.join(prefix, f)
}).join("\n").trim(), function (er) {
return cb(er, files)
})
// see if the spec is a url
// otherwise, treat as name@version
- var p = url.parse(spec.replace(/^git\+/, "git")) || {}
+ var p = url.parse(spec) || {}
log.verbose(p, "parsed url")
// it could be that we got name@http://blah
case "https:":
return addRemoteTarball(spec, null, name, cb)
case "git:":
- case "githttp:":
- case "githttps:":
- case "gitrsync:":
- case "gitftp:":
- case "gitssh:":
+ case "git+http:":
+ case "git+https:":
+ case "git+rsync:":
+ case "git+ftp:":
+ case "git+ssh:":
//p.protocol = p.protocol.replace(/^git([^:])/, "$1")
return addRemoteGit(spec, p, name, cb)
default:
}
function makeCacheDir (cb) {
- if (!process.getuid) return mkdir(npm.cache, npm.modes.exec, cb)
+ if (!process.getuid) return mkdir(npm.cache, cb)
var uid = +process.getuid()
, gid = +process.getgid()
}
if (uid !== 0 || !process.env.HOME) {
cacheStat = {uid: uid, gid: gid}
- return mkdir(npm.cache, npm.modes.exec, uid, gid, function (er) {
- return cb(er, cacheStat)
- })
+ return mkdir(npm.cache, afterMkdir)
}
+
fs.stat(process.env.HOME, function (er, st) {
if (er) return log.er(cb, "homeless?")(er)
cacheStat = st
log.silly([st.uid, st.gid], "uid, gid for cache dir")
- return mkdir(npm.cache, npm.modes.exec, st.uid, st.gid, function (er) {
+ return mkdir(npm.cache, afterMkdir)
+ })
+
+ function afterMkdir (er, made) {
+ if (er || !cacheStat || isNaN(cacheStat.uid) || isNaN(cacheStat.gid)) {
+ return cb(er, cacheStat)
+ }
+
+ if (!made) return cb(er, cacheStat)
+
+ // ensure that the ownership is correct.
+ chownr(made, cacheStat.uid, cacheStat.gid, function (er) {
return cb(er, cacheStat)
})
- })
+ }
}
, tgz = placeDirect ? placed : tmptgz
, doFancyCrap = p.indexOf(npm.tmp) !== 0
&& p.indexOf(npm.cache) !== 0
- tar.pack(tgz, p, data, doFancyCrap, function (er) {
- if (er) return log.er(cb,"couldn't pack "+p+ " to "+tgz)(er)
- addLocalTarball(tgz, name, cb)
+ getCacheStat(function (er, cs) {
+ mkdir(path.dirname(tgz), function (er, made) {
+ if (er) return cb(er)
+ tar.pack(tgz, p, data, doFancyCrap, function (er) {
+ if (er) return log.er(cb,"couldn't pack "+p+ " to "+tgz)(er)
+
+ if (er || !cs || isNaN(cs.uid) || isNaN(cs.gid)) return cb()
+
+ chownr(made || tgz, cs.uid, cs.gid, function (er) {
+ if (er) return cb(er)
+ addLocalTarball(tgz, name, cb)
+ })
+ })
+ })
})
})
}
if (!cb) cb = name, name = ""
getCacheStat(function (er, cs) {
if (er) return cb(er)
- return addTmpTarball_(tgz, name, cs.uid, cs.gid, cb)
- })
-}
-
-function addTmpTarball_ (tgz, name, uid, gid, cb) {
- var contents = path.resolve(path.dirname(tgz)) // , "contents")
- tar.unpack( tgz, path.resolve(contents, "package")
- , null, null
- , uid, gid
- , function (er) {
- if (er) return log.er(cb, "couldn't unpack "+tgz+" to "+contents)(er)
- fs.readdir(contents, function (er, folder) {
- if (er) return log.er(cb, "couldn't readdir "+contents)(er)
- log.verbose(folder, "tarball contents")
- if (folder.length > 1) {
- folder = folder.filter(function (f) {
- return !f.match(/^\.|^tmp\.tgz$/)
- })
- }
- if (folder.length > 1) {
- log.warn(folder.slice(1).join("\n")
- ,"extra junk in folder, ignoring")
+ var contents = path.dirname(tgz)
+ tar.unpack( tgz, path.resolve(contents, "package")
+ , null, null
+ , cs.uid, cs.gid
+ , function (er) {
+ if (er) {
+ return cb(er)
}
- if (!folder.length) return cb(new Error("Empty package tarball"))
- folder = path.join(contents, folder[0])
- var newName = path.join(contents, "package")
- fs.rename(folder, newName, function (er) {
- if (er) return log.er(cb, "couldn't rename "+folder+" to package")(er)
- addLocalDirectory(newName, name, cb)
- })
+ addLocalDirectory(path.resolve(contents, "package"), name, cb)
})
})
}
log.error("Could not read data for "+pkg+"@"+ver)
return cb(er)
}
- tar.unpack( path.join(npm.cache, pkg, ver, "package.tgz")
- , unpackTarget
- , dMode, fMode
- , uid, gid
- , cb )
+ npm.commands.unbuild([unpackTarget], function (er) {
+ if (er) return cb(er)
+ tar.unpack( path.join(npm.cache, pkg, ver, "package.tgz")
+ , unpackTarget
+ , dMode, fMode
+ , uid, gid
+ , cb )
+ })
})
}
module.exports = config
config.usage = "npm config set <key> <value>"
- + "\nnpm config get <key>"
+ + "\nnpm config get [<key>]"
+ "\nnpm config delete <key>"
+ "\nnpm config list"
+ "\nnpm config edit"
+ + "\nnpm set <key> <value>"
+ + "\nnpm get [<key>]"
var ini = require("./utils/ini.js")
, log = require("./utils/log.js")
}
function set (key, val, cb) {
+ if (key === undefined) {
+ return unknown("", cb)
+ }
if (val === undefined) {
if (key.indexOf("=") !== -1) {
var k = key.split("=")
if (homepage) return open(homepage, cb)
if (repo) {
if (Array.isArray(repo)) repo = repo.shift()
- if (repo.url) repo = repo.url
+ if (repo.hasOwnProperty("url")) repo = repo.url
log.verbose(repo, "repository")
if (repo) {
return open(repo.replace(/^git(@|:\/\/)/, 'http://')
, function (er, r) {
if (er) return cb(er)
if (r !== "none") {
- data.repository = (data.repository || {}).url = r
+ data.repository = (data.repository || {})
+ data.repository.url = r
+ } else {
+ delete data.repository
}
cb()
}
(data.scripts = data.scripts || {}).test = t
}
)
- ( read
- , [ { prompt: "What versions of node does it run on? "
- , default: data.engines && data.engines.node || (eng) } ]
- , function (nodever) {
- (data.engines = data.engines || {}).node = nodever
- }
- )
(cleanupPaths, [data, folder])
(function (cb) {
try { data = readJson.processJson(data) }
-
// npm install <pkg> <pkg> <pkg>
//
// See doc/install.md for more description
-// Managing "family" lists...
-// every time we dive into a deeper node_modules folder, the "family"
-// list that gets passed along uses the previous "family" list as
-// it's __proto__. Any "resolved precise dependency" things that aren't
-// already on this object get added, and then that's passed to the next
-// generation of installation.
+// Managing contexts...
+// there's a lot of state associated with an "install" operation, including
+// packages that are already installed, parent packages, current shrinkwrap, and
+// so on. We maintain this state in a "context" object that gets passed around.
+// every time we dive into a deeper node_modules folder, the "family" list that
+// gets passed along uses the previous "family" list as its __proto__. Any
+// "resolved precise dependency" things that aren't already on this object get
+// added, and then that's passed to the next generation of installation.
module.exports = install
+ "\nnpm install <pkg>@<version>"
+ "\nnpm install <pkg>@<version range>"
+ "\n\nCan specify one or more: npm install ./foo.tgz bar@stable /some/folder"
- + "\nInstalls dependencies in ./package.json if no argument supplied"
+ + "\nIf no argument is supplied and ./npm-shrinkwrap.json is "
+ + "\npresent, installs dependencies specified in the shrinkwrap."
+ + "\nOtherwise, installs dependencies from ./package.json."
install.completion = function (opts, cb) {
// install can complete to a folder with a package.json, or any package.
, relativize = require("./utils/relativize.js")
, output
, url = require("url")
- , mkdir = require("./utils/mkdir-p.js")
+ , mkdir = require("mkdirp")
, lifecycle = require("./utils/lifecycle.js")
+ , archy = require("archy")
function install (args, cb_) {
output = output || require("./utils/output.js")
var tree = treeify(installed)
- , pretty = prettify(tree, installed)
+ , pretty = prettify(tree, installed).trim()
+
+ if (pretty) output.write(pretty, afterWrite)
+ else afterWrite()
- output.write(pretty, function (er) {
+ function afterWrite (er) {
if (er) return cb_(er)
save(where, installed, tree, pretty, cb_)
- })
+ }
}
// the /path/to/node_modules/..
})
}
- mkdir(where, function (er) {
+ mkdir(where, function (er, made) {
if (er) return cb(er)
// install dependencies locally by default,
// or install current folder globally
if (!args.length) {
if (npm.config.get("global")) args = ["."]
- else return readJson( path.resolve(where, "package.json")
- , { dev: !npm.config.get("production") }
- , function (er, data) {
+ else return readDependencies( null
+ , where
+ , { dev: !npm.config.get("production") }
+ , function (er, data) {
if (er) return log.er(cb, "Couldn't read dependencies.")(er)
var deps = Object.keys(data.dependencies || {})
log.verbose([where, deps], "where, deps")
- var family = {}
- , ancestors = {}
- family[data.name] = ancestors[data.name] = data.version
+ var context = { family: {}
+ , ancestors: {}
+ , explicit: false
+ , parent: data
+ , wrap: null }
+ context.family[data.name] = context.ancestors[data.name] = data.version
installManyTop(deps.map(function (dep) {
var target = data.dependencies[dep]
, parsed = url.parse(target.replace(/^git\+/, "git"))
target = dep + "@" + target
return target
- }), where, family, ancestors, false, data, cb)
+ }), where, context, cb)
})
}
// initial "family" is the name:version of the root, if it's got
- // a pacakge.json file.
+ // a package.json file.
readJson(path.resolve(where, "package.json"), function (er, data) {
if (er) data = null
- var family = {}
- , ancestors = {}
- if (data) family[data.name] = ancestors[data.name] = data.version
+ var context = { family: {}
+ , ancestors: {}
+ , explicit: true
+ , parent: data
+ , wrap: null }
+ if (data) {
+ context.family[data.name] = context.ancestors[data.name] = data.version
+ }
var fn = npm.config.get("global") ? installMany : installManyTop
- fn(args, where, family, ancestors, true, data, cb)
+ fn(args, where, context, cb)
+ })
+ })
+}
+
+// reads dependencies for the package at "where". There are several cases,
+// depending on our current state and the package's configuration:
+//
+// 1. If "context" is specified, then we examine the context to see if there's a
+// shrinkwrap there. In that case, dependencies are read from the shrinkwrap.
+// 2. Otherwise, if an npm-shrinkwrap.json file is present, dependencies are
+// read from there.
+// 3. Otherwise, dependencies come from package.json.
+//
+// Regardless of which case we fall into, "cb" is invoked with a first argument
+// describing the full package (as though readJson had been used) but with
+// "dependencies" read as described above. The second argument to "cb" is the
+// shrinkwrap to use in processing this package's dependencies, which may be
+// "wrap" (in case 1) or a new shrinkwrap (in case 2).
+function readDependencies (context, where, opts, cb) {
+ var wrap = context ? context.wrap : null
+
+ readJson( path.resolve(where, "package.json")
+ , opts
+ , function (er, data) {
+ if (er) return cb(er)
+
+ if (wrap) {
+ log.verbose([where, wrap], "readDependencies: using existing wrap")
+ var rv = {}
+ Object.keys(data).forEach(function (key) {
+ rv[key] = data[key]
+ })
+ rv.dependencies = {}
+ Object.keys(wrap).forEach(function (key) {
+ log.verbose([key, wrap[key]], "from wrap")
+ var w = wrap[key]
+ rv.dependencies[key] = w.from || w.version
+ })
+ log.verbose([rv.dependencies], "readDependencies: returned deps")
+ return cb(null, rv, wrap)
+ }
+
+ var wrapfile = path.resolve(where, "npm-shrinkwrap.json")
+
+ fs.readFile(wrapfile, "utf8", function (er, wrapjson) {
+ if (er) {
+ log.verbose("readDependencies: using package.json deps")
+ return cb(null, data, null)
+ }
+
+ try {
+ var newwrap = JSON.parse(wrapjson)
+ } catch (ex) {
+ return cb(ex)
+ }
+
+ log.info(wrapfile, "using shrinkwrap file")
+ var rv = {}
+ Object.keys(data).forEach(function (key) {
+ rv[key] = data[key]
+ })
+ rv.dependencies = {}
+ Object.keys(newwrap.dependencies || {}).forEach(function (key) {
+ var w = newwrap.dependencies[key]
+ rv.dependencies[key] = w.from || w.version
+ })
+ log.verbose([rv.dependencies], "readDependencies: returned deps")
+ return cb(null, rv, newwrap.dependencies)
})
})
}
// as dependencies to a package.json file.
// This is experimental.
function save (where, installed, tree, pretty, cb) {
- if (!npm.config.get("save") || npm.config.get("global")) {
+ if (!npm.config.get("save") &&
+ !npm.config.get("save-dev") &&
+ !npm.config.get("save-optional") ||
+ npm.config.get("global")) {
return cb(null, installed, tree, pretty)
}
+
// each item in the tree is a top-level thing that should be saved
// to the package.json file.
// The relevant tree shape is { <folder>: {what:<pkg>} }
var saveTarget = path.resolve(where, "package.json")
, things = Object.keys(tree).map(function (k) {
- return tree[k].what.split("@")
+ // if "what" was a url, then save that instead.
+ var t = tree[k]
+ , u = url.parse(t.from)
+ , w = t.what.split("@")
+ if (u && u.protocol) w[1] = t.from
+ return w
}).reduce(function (set, k) {
- var rangeDescriptor = semver.gte(k[1], "0.1.0") ? "~" : ""
+ var rangeDescriptor = semver.valid(k[1]) &&
+ semver.gte(k[1], "0.1.0")
+ ? "~" : ""
set[k[0]] = rangeDescriptor + k[1]
return set
}, {})
} catch (ex) {
er = ex
}
- if (er) return cb(null, installed, tree, pretty)
+ if (er) {
+ return cb(null, installed, tree, pretty)
- var deps = npm.config.get("dev") ? "devDependencies" : "dependencies"
- deps = data[deps] = data[deps] || {}
+ }
+
+ var deps = npm.config.get("save-optional") ? "optionalDependencies"
+ : npm.config.get("save-dev") ? "devDependencies"
+ : "dependencies"
+ data[deps] = data[deps] || {}
Object.keys(things).forEach(function (t) {
- deps[t] = things[t]
+ data[deps][t] = things[t]
})
data = JSON.stringify(data, null, 2) + "\n"
fs.writeFile(saveTarget, data, function (er) {
// Outputting *all* the installed modules is a bit confusing,
// because the length of the path does not make it clear
// that the submodules are not immediately require()able.
-// TODO: Show the complete tree, ls-style.
+// TODO: Show the complete tree, ls-style, but only if --long is provided
function prettify (tree, installed) {
- if (npm.config.get("parseable")) return parseable(installed)
- return Object.keys(tree).map(function (p) {
- p = tree[p]
- var c = ""
- if (p.children && p.children.length) {
- pref = "\n"
- var l = p.children.pop()
- c = p.children.map(function (c) {
- var gc = c.children && c.children.length
- ? " (" + c.children.map(function (gc) {
- return gc.what
- }).join(" ") + ")"
- : ""
- return "\n├── " + c.what + gc
- }).join("") + "\n└── " + l.what
+ if (npm.config.get("json")) {
+ function red (set, kv) {
+ set[kv[0]] = kv[1]
+ return set
}
- return [p.what, p.where, c].join(" ")
+ tree = Object.keys(tree).map(function (p) {
+ if (!tree[p]) return null
+ var what = tree[p].what.split("@")
+ , name = what.shift()
+ , version = what.join("@")
+ , o = { name: name, version: version, from: tree[p].from }
+ o.dependencies = tree[p].children.map(function P (dep) {
+ var what = dep.what.split("@")
+ , name = what.shift()
+ , version = what.join("@")
+ , o = { version: version, from: dep.from }
+ o.dependencies = dep.children.map(P).reduce(red, {})
+ return [name, o]
+ }).reduce(red, {})
+ return o
+ })
+
+ return JSON.stringify(tree, null, 2)
+ }
+ if (npm.config.get("parseable")) return parseable(installed)
+
+ return Object.keys(tree).map(function (p) {
+ return archy({ label: tree[p].what + " " + p
+ , nodes: (tree[p].children || []).map(function P (c) {
+ if (npm.config.get("long")) {
+ return { label: c.what, nodes: c.children.map(P) }
+ }
+ var g = c.children.map(function (g) {
+ return g.what
+ }).join(", ")
+ if (g) g = " (" + g + ")"
+ return c.what + g
+ })
+ })
}).join("\n")
}
, parent = r[2]
, where = r[1]
, what = r[0]
+ , from = r[4]
l[where] = { parentDir: parentDir
, parent: parent
, children: []
, where: where
- , what: what }
+ , what: what
+ , from: from }
return l
}, {})
// just like installMany, but also add the existing packages in
// where/node_modules to the family object.
-function installManyTop (what, where, family, ancestors, explicit, parent, cb_) {
-
+function installManyTop (what, where, context, cb_) {
function cb (er, d) {
- if (explicit || er) return cb_(er, d)
+ if (context.explicit || er) return cb_(er, d)
// since this wasn't an explicit install, let's build the top
// folder, so that `npm install` also runs the lifecycle scripts.
npm.commands.build([where], false, true, function (er) {
})
}
- if (explicit) return next()
+ if (context.explicit) return next()
readJson(path.join(where, "package.json"), function (er, data) {
if (er) return next(er)
function next (er) {
if (er) return cb(er)
- installManyTop_(what, where, family, ancestors, explicit, parent, cb)
+ installManyTop_(what, where, context, cb)
}
}
-function installManyTop_ (what, where, family, ancestors, explicit, parent, cb) {
+function installManyTop_ (what, where, context, cb) {
var nm = path.resolve(where, "node_modules")
- , names = explicit
+ , names = context.explicit
? what.map(function (w) { return w.split(/@/).shift() })
: []
fs.readdir(nm, function (er, pkgs) {
- if (er) return installMany(what, where, family, ancestors, explicit, parent, cb)
+ if (er) return installMany(what, where, context, cb)
pkgs = pkgs.filter(function (p) {
return !p.match(/^[\._-]/)
- && (!explicit || names.indexOf(p) === -1)
})
asyncMap(pkgs.map(function (p) {
return path.resolve(nm, p, "package.json")
// add all the existing packages to the family list.
// however, do not add to the ancestors list.
packages.forEach(function (p) {
- family[p[0]] = p[1]
+ context.family[p[0]] = p[1]
})
- return installMany(what, where, family, ancestors, explicit, parent, cb)
+ return installMany(what, where, context, cb)
})
})
}
-function installMany (what, where, family, ancestors, explicit, parent, cb) {
- // 'npm install foo' should install the version of foo
- // that satisfies the dep in the current folder.
- // This will typically return immediately, since we already read
- // this file family, and it'll be cached.
- readJson(path.resolve(where, "package.json"), function (er, data) {
+function installMany (what, where, context, cb) {
+ // readDependencies takes care of figuring out whether the list of
+ // dependencies we'll iterate below comes from an existing shrinkwrap from a
+ // parent level, a new shrinkwrap at this level, or package.json at this
+ // level, as well as which shrinkwrap (if any) our dependencies should use.
+ readDependencies(context, where, {}, function (er, data, wrap) {
if (er) data = {}
- d = data.dependencies || {}
var parent = data
+ var d = data.dependencies || {}
+
+ // if we're explicitly installing "what" into "where", then the shrinkwrap
+ // for "where" doesn't apply. This would be the case if someone were adding
+ // a new package to a shrinkwrapped package. (data.dependencies will not be
+ // used here except to indicate what packages are already present, so
+ // there's no harm in using that.)
+ if (context.explicit) wrap = null
+
// what is a list of things.
// resolve each one.
asyncMap( what
- , targetResolver(where, family, ancestors, explicit, d, parent)
+ , targetResolver(where, context, d)
, function (er, targets) {
if (er) return cb(er)
// each target will be a data object corresponding
// to a package, folder, or whatever that is in the cache now.
- var newPrev = Object.create(family)
- , newAnc = Object.create(ancestors)
+ var newPrev = Object.create(context.family)
+ , newAnc = Object.create(context.ancestors)
newAnc[data.name] = data.version
targets.forEach(function (t) {
log.info(t._id, "into "+where)
})
asyncMap(targets, function (target, cb) {
- log(target._id, "installOne")
- installOne(target, where, newPrev, newAnc, parent, cb)
+ log.info(target._id, "installOne")
+ var newWrap = wrap ? wrap[target.name].dependencies || {} : null
+ var newContext = { family: newPrev
+ , ancestors: newAnc
+ , parent: parent
+ , explicit: false
+ , wrap: newWrap }
+ installOne(target, where, newContext, cb)
}, cb)
})
})
}
-function targetResolver (where, family, ancestors, explicit, deps, parent) {
- var alreadyInstalledManually = explicit ? [] : null
+function targetResolver (where, context, deps) {
+ var alreadyInstalledManually = context.explicit ? [] : null
, nm = path.resolve(where, "node_modules")
+ , parent = context.parent
+ , wrap = context.wrap
- if (!explicit) fs.readdir(nm, function (er, inst) {
+ if (!context.explicit) fs.readdir(nm, function (er, inst) {
if (er) return alreadyInstalledManually = []
asyncMap(inst, function (pkg, cb) {
readJson(path.resolve(nm, pkg, "package.json"), function (er, d) {
+ // error means it's not a package, most likely.
if (er) return cb(null, [])
- if (semver.satisfies(d.version, deps[d.name] || "*")) {
+
+ // if it's a bundled dep, then assume that anything there is valid.
+ // otherwise, make sure that it's a semver match with what we want.
+ var bd = parent.bundleDependencies
+ if (bd && bd.indexOf(d.name) !== -1 ||
+ semver.satisfies(d.version, deps[d.name] || "*")) {
return cb(null, d.name)
}
+
+ // something is there, but it's not satisfactory. Clobber it.
return cb(null, [])
})
}, function (er, inst) {
if (!alreadyInstalledManually) return setTimeout(function () {
resolver(what, cb)
}, to++)
+
// now we know what's been installed here manually,
// or tampered with in some way that npm doesn't want to overwrite.
if (alreadyInstalledManually.indexOf(what.split("@").shift()) !== -1) {
return cb(null, [])
}
- if (family[what] && semver.satisfies(family[what], deps[what] || "")) {
+ // check for a version installed higher in the tree.
+ // If installing from a shrinkwrap, it must match exactly.
+ if (context.family[what]) {
+ if (wrap && wrap[what].version === context.family[what]) {
+ log.verbose(what, "using existing (matches shrinkwrap)")
+ return cb(null, [])
+ }
+ }
+
+ // if it's identical to its parent, then it's probably someone
+ // doing `npm install foo` inside of the foo project. Print
+ // a warning, and skip it.
+ if (parent && parent.name === what && !npm.config.get("force")) {
+ log.warn("Refusing to install "+what+" as a dependency of itself"
+ ,"install")
return cb(null, [])
}
- if (deps[what]) {
+ if (wrap) {
+ name = what.split(/@/).shift()
+ if (wrap[name]) {
+ var wrapTarget = wrap[name].from || wrap[name].version
+ log.verbose("resolving "+what+" to "+wrapTarget, "shrinkwrap")
+ what = name + "@" + wrapTarget
+ } else {
+ log.verbose("skipping "+what+" (not in shrinkwrap)", "shrinkwrap")
+ }
+ } else if (deps[what]) {
what = what + "@" + deps[what]
}
cache.add(what, function (er, data) {
if (er && parent && parent.optionalDependencies &&
- parent.optionalDependencies.hasOwnProperty(what.split("@").shift())) {
+ parent.optionalDependencies.hasOwnProperty(what.split("@")[0])) {
log.warn(what, "optional dependency failed, continuing")
+ log.verbose([what, er], "optional dependency failed, continuing")
return cb(null, [])
}
- if (!er && data && family[data.name] === data.version) {
+
+ if (!er &&
+ data &&
+ !context.explicit &&
+ context.family[data.name] === data.version &&
+ !npm.config.get("force")) {
+ log.info(data.name + "@" + data.version, "already installed")
return cb(null, [])
}
+
+ if (data) data._from = what
+
return cb(er, data)
})
}
// we've already decided to install this. if anything's in the way,
// then uninstall it first.
-function installOne (target, where, family, ancestors, parent, cb) {
+function installOne (target, where, context, cb) {
// the --link flag makes this a "link" command if it's at the
// the top level.
if (where === npm.prefix && npm.config.get("link")
&& !npm.config.get("global")) {
- return localLink(target, where, family, ancestors, parent, cb)
+ return localLink(target, where, context, cb)
}
- installOne_(target, where, family, ancestors, parent, cb)
+ installOne_(target, where, context, function (er, installedWhat) {
+
+ // check if this one is optional to its parent.
+ if (er && context.parent && context.parent.optionalDependencies &&
+ context.parent.optionalDependencies.hasOwnProperty(target.name)) {
+ log.warn(target._id, "optional dependency failed, continuing")
+ log.verbose([target._id, er], "optional dependency failed, continuing")
+ er = null
+ }
+
+ cb(er, installedWhat)
+ })
+
}
-function localLink (target, where, family, ancestors, parent, cb) {
+function localLink (target, where, context, cb) {
log.verbose(target._id, "try to link")
var jsonFile = path.resolve( npm.dir, target.name
, "package.json" )
+ , parent = context.parent
readJson(jsonFile, function (er, data) {
if (er || data._id === target._id) {
} else {
log.verbose(target._id, "install locally (no link)")
- installOne_(target, where, family, ancestors, parent, cb)
+ installOne_(target, where, context, cb)
}
})
}
return [ target._id
, targetFolder
, prettyWhere && parentId
- , parentId && prettyWhere ]
+ , parentId && prettyWhere
+ , target._from ]
}
-function installOne_ (target, where, family, ancestors, parent, cb) {
+function installOne_ (target, where, context, cb) {
var nm = path.resolve(where, "node_modules")
, targetFolder = path.resolve(nm, target.name)
, prettyWhere = relativize(where, process.cwd() + "/x")
+ , parent = context.parent
if (prettyWhere === ".") prettyWhere = null
chain
( [ [checkEngine, target]
- , [checkCycle, target, ancestors]
+ , [checkPlatform, target]
+ , [checkCycle, target, context.ancestors]
, [checkGit, targetFolder]
- , [write, target, targetFolder, family, ancestors] ]
+ , [write, target, targetFolder, context] ]
, function (er, d) {
- log.verbose(target._id, "installOne cb")
if (er) return cb(er)
d.push(resultList(target, where, parent && parent._id))
cb(er, d)
return cb()
}
+function checkPlatform (target, cb) {
+ var platform = process.platform
+ , arch = process.arch
+ , osOk = true
+ , cpuOk = true
+ , force = npm.config.get("force")
+
+ if (force) {
+ return cb()
+ }
+
+ if (target.os) {
+ osOk = checkList(platform, target.os)
+ }
+ if (target.cpu) {
+ cpuOk = checkList(arch, target.cpu)
+ }
+ if (!osOk || !cpuOk) {
+ var er = new Error("Unsupported")
+ er.errno = npm.EBADPLATFORM
+ er.os = target.os || ['any']
+ er.cpu = target.cpu || ['any']
+ er.pkgid = target._id
+ return cb(er)
+ }
+ return cb()
+}
+
+function checkList (value, list) {
+ var tmp
+ , match = false
+ , blc = 0
+ if (typeof list === "string") {
+ list = [list]
+ }
+ if (list.length === 1 && list[0] === "any") {
+ return true;
+ }
+ for (var i = 0; i < list.length; ++i) {
+ tmp = list[i]
+ if (tmp[0] === '!') {
+ tmp = tmp.slice(1)
+ if (tmp === value) {
+ return false;
+ }
+ ++blc
+ } else {
+ match = match || tmp === value
+ }
+ }
+ return match || blc === list.length
+}
function checkCycle (target, ancestors, cb) {
// there are some very rare and pathological edge-cases where
// A more correct, but more complex, solution would be to symlink
// the deeper thing into the new location.
// Will do that if anyone whines about this irl.
-
- var p = Object.getPrototypeOf(ancestors)
+ //
+ // Note: `npm install foo` inside of the `foo` package will abort
+ // earlier if `--force` is not set. However, if it IS set, then
+ // we need to still fail here, but just skip the first level. Of
+ // course, it'll still fail eventually if it's a true cycle, and
+ // leave things in an undefined state, but that's what is to be
+ // expected when `--force` is used. That is why getPrototypeOf
+ // is used *twice* here: to skip the first level of repetition.
+
+ var p = Object.getPrototypeOf(Object.getPrototypeOf(ancestors))
, name = target.name
, version = target.version
while (p && p !== Object.prototype && p[name] !== version) {
})
}
-function write (target, targetFolder, family, ancestors, cb_) {
+function write (target, targetFolder, context, cb_) {
var up = npm.config.get("unsafe-perm")
, user = up ? null : npm.config.get("user")
, group = up ? null : npm.config.get("group")
+ , family = context.family
function cb (er, data) {
// cache.unpack returns the data object, and all we care about
// is the list of installed packages from that last thing.
if (!er) return cb_(er, data)
- log.error(target._id,"error installing")
+
if (false === npm.config.get("rollback")) return cb_(er)
npm.commands.unbuild([targetFolder], function (er2) {
if (er2) log.error(er2, "error rolling back "+target._id)
})
}
+ var bundled = []
+
chain
- ( [ [ npm.commands.unbuild, [targetFolder] ]
- , [ cache.unpack, target.name, target.version, targetFolder
+ ( [ [ cache.unpack, target.name, target.version, targetFolder
, null, null, user, group ]
- , [ lifecycle, target, "preinstall", targetFolder ] ]
+ , [ fs, "writeFile"
+ , path.resolve(targetFolder, "package.json")
+ , JSON.stringify(target, null, 2) + "\n" ]
+ , [ lifecycle, target, "preinstall", targetFolder ]
+ , function (cb) {
+ if (!target.bundleDependencies) return cb()
+
+ var bd = path.resolve(targetFolder, "node_modules")
+ fs.readdir(bd, function (er, b) {
+ // nothing bundled, maybe
+ if (er) return cb()
+ bundled = b || []
+ cb()
+ })
+ } ]
// nest the chain so that we can throw away the results returned
// up until this point, since we really don't care about it.
- , function (er) {
+ , function X (er) {
if (er) return cb(er)
- var deps = Object.keys(target.dependencies || {})
- installMany(deps.filter(function (d) {
- // prefer to not install things that are satisfied by
- // something in the "family" list.
- return !semver.satisfies(family[d], target.dependencies[d])
- }).map(function (d) {
- var t = target.dependencies[d]
- , parsed = url.parse(t.replace(/^git\+/, "git"))
- t = d + "@" + t
- return t
- }), targetFolder, family, ancestors, false, target, function (er, d) {
- log.verbose(targetFolder, "about to build")
- if (er) return cb(er)
- npm.commands.build( [targetFolder]
- , npm.config.get("global")
- , true
- , function (er) { return cb(er, d) })
+
+ // before continuing to installing dependencies, check for a shrinkwrap.
+ readDependencies(context, targetFolder, {}, function (er, data, wrap) {
+ var deps = Object.keys(data.dependencies || {})
+
+ // don't install bundleDependencies, unless they're missing.
+ if (data.bundleDependencies) {
+ deps = deps.filter(function (d) {
+ return data.bundleDependencies.indexOf(d) === -1 ||
+ bundled.indexOf(d) === -1
+ })
+ }
+
+ var newcontext = { family: family
+ , ancestors: context.ancestors
+ , parent: target
+ , explicit: false
+ , wrap: wrap }
+ installMany(deps.filter(function (d) {
+ // prefer to not install things that are satisfied by
+ // something in the "family" list, unless we're installing
+ // from a shrinkwrap.
+ return wrap || !semver.satisfies(family[d], data.dependencies[d])
+ }).map(function (d) {
+ var t = data.dependencies[d]
+ , parsed = url.parse(t.replace(/^git\+/, "git"))
+ t = d + "@" + t
+ return t
+ }), targetFolder, newcontext, function (er, d) {
+ log.verbose(targetFolder, "about to build")
+ if (er) return cb(er)
+ npm.commands.build( [targetFolder]
+ , npm.config.get("global")
+ , true
+ , function (er) { return cb(er, d) })
+ })
})
- } )
+ })
}
var where = relativize(dest, path.resolve(process.cwd(),"x"))
rp = (rp || "").trim()
src = (src || "").trim()
+ // XXX If --json is set, then look up the data from the package.json
if (npm.config.get("parseable")) {
return parseableOutput(dest, rp || src, cb)
}
}
function parseableOutput (dest, rp, cb) {
+ // XXX this should match ls --parseable and install --parseable
+ // look up the data from package.json, format it the same way.
+ //
// link is always effectively "long", since it doesn't help much to
// *just* print the target folder.
// However, we don't actually ever read the version number, so
, log = require("./utils/log.js")
, relativize = require("./utils/relativize.js")
, path = require("path")
+ , archy = require("archy")
ls.usage = "npm ls"
var dir = path.resolve(npm.dir, "..")
readInstalled(dir, function (er, data) {
- if (er || silent) return cb(er, data)
+ var lite = getLite(bfsify(data))
+ if (er || silent) return cb(er, data, lite)
+
var long = npm.config.get("long")
- var out = makePretty(bfsify(data), long, dir).join("\n")
- output.write(out, function (er) { cb(er, data) })
+ , json = npm.config.get("json")
+ , out
+ if (json) {
+ var seen = []
+ var d = long ? bfsify(data) : lite
+ // the raw data can be circular
+ out = JSON.stringify(d, function (k, o) {
+ if (typeof o === "object") {
+ if (-1 !== seen.indexOf(o)) return "[Circular]"
+ seen.push(o)
+ }
+ return o
+ }, 2)
+ } else if (npm.config.get("parseable")) {
+ out = makeParseable(bfsify(data), long, dir)
+ } else if (data) {
+ out = makeArchy(bfsify(data), long, dir)
+ }
+ output.write(out, function (er) { cb(er, data, lite) })
})
}
+function alphasort (a, b) {
+ a = a.toLowerCase()
+ b = b.toLowerCase()
+ return a > b ? 1
+ : a < b ? -1 : 0
+}
+
+function getLite (data, noname) {
+ var lite = {}
+ , maxDepth = npm.config.get("depth")
+ , url = require("url")
+
+ if (!noname && data.name) lite.name = data.name
+ if (data.version) lite.version = data.version
+ if (data.extraneous) {
+ lite.extraneous = true
+ lite.problems = lite.problems || []
+ lite.problems.push( "extraneous: "
+ + data.name + "@" + data.version
+ + " " + (data.path || "") )
+ }
+
+ if (data._from) {
+ var from = data._from
+ if (from.indexOf(data.name + "@") === 0) {
+ from = from.substr(data.name.length + 1)
+ }
+ var u = url.parse(from)
+ if (u.protocol) lite.from = from
+ }
+
+ if (data.invalid) {
+ lite.invalid = true
+ lite.problems = lite.problems || []
+ lite.problems.push( "invalid: "
+ + data.name + "@" + data.version
+ + " " + (data.path || "") )
+ }
+
+ if (data.dependencies) {
+ var deps = Object.keys(data.dependencies)
+ if (deps.length) lite.dependencies = deps.map(function (d) {
+ var dep = data.dependencies[d]
+ if (typeof dep === "string") {
+ lite.problems = lite.problems || []
+ var p
+ if (data.depth >= maxDepth) {
+ p = "max depth reached: "
+ } else {
+ p = "missing: "
+ }
+ p += d + "@" + dep
+ + ", required by "
+ + data.name + "@" + data.version
+ lite.problems.push(p)
+ return [d, { required: dep, missing: true }]
+ }
+ return [d, getLite(dep, true)]
+ }).reduce(function (deps, d) {
+ if (d[1].problems) {
+ lite.problems = lite.problems || []
+ lite.problems.push.apply(lite.problems, d[1].problems)
+ }
+ deps[d[0]] = d[1]
+ return deps
+ }, {})
+ }
+ return lite
+}
+
function bfsify (root, current, queue, seen) {
// walk over the data, and turn it from this:
// +-- a
// which looks nicer
current = current || root
queue = queue || []
- seen = seen || []
+ seen = seen || [root]
var deps = current.dependencies = current.dependencies || {}
Object.keys(deps).forEach(function (d) {
var dep = deps[d]
}
-function makePretty (data, long, dir, prefix, list) {
- var top = !list
- list = list || []
- prefix = prefix || ""
- list.push(format(data, long, prefix, dir))
- var deps = data.dependencies || {}
- , childPref = prefix.split("├─").join("│ ")
- .split("└─").join(" ")
- , depList = Object.keys(deps)
- , depLast = depList.length - 1
- , maxDepth = npm.config.get("depth")
- Object.keys(deps).sort(function (a, b) {
- return a > b ? 1 : -1
- }).forEach(function (d, i) {
- var depData = deps[d]
- if (typeof depData === "string") {
- if (data.depth < maxDepth) {
- var p = data.link || data.path
- log.warn("Unmet dependency in "+p, d+" "+deps[d])
- depData = npm.config.get("parseable")
- ? ( npm.config.get("long")
- ? path.resolve(data.path, "node_modules", d)
- + ":"+d+"@"+JSON.stringify(depData)+":INVALID:MISSING"
- : "" )
- : "─ \033[31;40mUNMET DEPENDENCY\033[0m "+d+" "+depData
- } else {
- if (npm.config.get("parseable")) {
- depData = path.resolve(data.path, "node_modules", d)
- + (npm.config.get("long")
- ? ":" + d + "@" + JSON.stringify(depData)
- + ":" // no realpath resolved
- + ":MAXDEPTH"
- : "")
- } else {
- depData = "─ "+d+"@'"+depData +"' (max depth reached)"
- }
- }
- }
- var c = i === depLast ? "└─" : "├─"
- makePretty(depData, long, dir, childPref + c, list)
- })
- if (top && list.length === 1 && !data._id) {
- if (!npm.config.get("parseable")) {
- list.push("(empty)")
- } else if (npm.config.get("long")) list[0] += ":EMPTY"
- }
- return list.filter(function (l) { return l && l.trim() })
+function makeArchy (data, long, dir) {
+ var out = makeArchy_(data, long, dir, 0)
+ return archy(out, "", { unicode: npm.config.get("unicode") })
}
-function ugly (data) {
+function makeArchy_ (data, long, dir, depth, parent, d) {
if (typeof data === "string") {
+ if (depth < npm.config.get("depth")) {
+ // just missing
+ var p = parent.link || parent.path
+ log.warn("Unmet dependency in "+p, d+" "+data)
+ data = "\033[31;40mUNMET DEPENDENCY\033[0m " + d + " " + data
+ } else {
+ data = d+"@'"+ data +"' (max depth reached)"
+ }
return data
}
- if (!npm.config.get("long")) return data.path
- return data.path
- + ":" + (data._id || "")
- + ":" + (data.realPath !== data.path ? data.realPath : "")
- + (data.extraneous ? ":EXTRANEOUS" : "")
- + (data.invalid ? ":INVALID" : "")
-}
+ var out = {}
+ // the top level is a bit special.
+ out.label = data._id ? data._id + " " : ""
+ if (data.link) out.label += "-> " + data.link
-function format (data, long, prefix, dir) {
- if (npm.config.get("parseable")) return ugly(data)
- if (typeof data === "string") {
- return prefix + data
- }
-// console.log([data.path, dir], "relativize")
- var depLen = Object.keys(data.dependencies).length
- , space = prefix.split("├─").join("│ ")
- .split("└─").join(" ")
- + (depLen ? "" : " ")
- , rel = relativize(data.path || "", dir)
- , l = prefix
- + (rel === "." ? "" : depLen ? "┬ " : "─ ")
- + (data._id ? data._id + " " : "")
- + (data.link ? "-> " + data.link : "") + ""
- + (rel === "." && !(long && data._id) ? dir : "")
if (data.invalid) {
- if (data.realName !== data.name) l += " ("+data.realName+")"
- l += " \033[31;40minvalid\033[0m"
+ if (data.realName !== data.name) out.label += " ("+data.realName+")"
+ out.label += " \033[31;40minvalid\033[0m"
}
- if (data.extraneous && rel !== ".") {
- l += " \033[32;40mextraneous\033[0m"
+
+ if (data.extraneous && data.path !== dir) {
+ out.label += " \033[32;40mextraneous\033[0m"
+ }
+
+ if (long) {
+ if (dir === data.path) out.label += "\n" + dir
+ out.label += "\n" + getExtras(data, dir)
+ } else if (dir === data.path) {
+ out.label += dir
+ }
+
+ // now all the children.
+ out.nodes = Object.keys(data.dependencies || {})
+ .sort(alphasort).map(function (d) {
+ return makeArchy_(data.dependencies[d], long, dir, depth + 1, data, d)
+ })
+
+ if (out.nodes.length === 0 && data.path === dir) {
+ out.nodes = ["(empty)"]
}
- if (!long || !data._id) return l
+
+ return out
+}
+
+function getExtras (data, dir) {
var extras = []
- if (rel !== ".") extras.push(rel)
- else extras.push(dir)
+ , rel = relativize(data.path || "", dir)
+ , url = require("url")
+
if (data.description) extras.push(data.description)
if (data.repository) extras.push(data.repository.url)
if (data.homepage) extras.push(data.homepage)
- extras = extras.filter(function (e) { return e })
- var lastExtra = !depLen && extras.length - 1
- l += extras.map(function (e, i) {
- var indent = !depLen ? " " : "│ "
- return "\n" + space + indent + e
- }).join("")
- return l
+ if (data._from) {
+ var from = data._from
+ if (from.indexOf(data.name + "@") === 0) {
+ from = from.substr(data.name.length + 1)
+ }
+ var u = url.parse(from)
+ if (u.protocol) extras.push(from)
+ }
+ return extras.join("\n")
+}
+
+
+function makeParseable (data, long, dir, depth, parent, d) {
+ depth = depth || 0
+
+ return [ makeParseable_(data, long, dir, depth, parent, d) ]
+ .concat(Object.keys(data.dependencies || {})
+ .sort(alphasort).map(function (d) {
+ return makeParseable(data.dependencies[d], long, dir, depth + 1, data, d)
+ }))
+ .join("\n")
+}
+
+function makeParseable_ (data, long, dir, depth, parent, d) {
+ if (typeof data === "string") {
+ if (data.depth < npm.config.get("depth")) {
+ var p = parent.link || parent.path
+ log.warn("Unmet dependency in "+p, d+" "+data)
+ data = npm.config.get("long")
+ ? path.resolve(parent.path, "node_modules", d)
+ + ":"+d+"@"+JSON.stringify(data)+":INVALID:MISSING"
+ : ""
+ } else {
+ data = path.resolve(data.path, "node_modules", d)
+ + (npm.config.get("long")
+ ? ":" + d + "@" + JSON.stringify(data)
+ + ":" // no realpath resolved
+ + ":MAXDEPTH"
+ : "")
+ }
+
+ return data
+ }
+
+ if (!npm.config.get("long")) return data.path
+
+ return data.path
+ + ":" + (data._id || "")
+ + ":" + (data.realPath !== data.path ? data.realPath : "")
+ + (data.extraneous ? ":EXTRANEOUS" : "")
+ + (data.invalid ? ":INVALID" : "")
}
var EventEmitter = require("events").EventEmitter
, npm = module.exports = new EventEmitter
, config = require("./config.js")
- , set = require("./utils/set.js")
- , get = require("./utils/get.js")
, ini = require("./utils/ini.js")
, log = require("./utils/log.js")
, fs = require("graceful-fs")
, which = require("which")
, semver = require("semver")
, findPrefix = require("./utils/find-prefix.js")
- , getUid = require("./utils/uid-number.js")
- , mkdir = require("./utils/mkdir-p.js")
+ , getUid = require("uid-number")
+ , mkdirp = require("mkdirp")
, slide = require("slide")
, chain = slide.chain
+// /usr/local is often a read-only fs, which is not
+// well handled by node or mkdirp. Just double-check
+// in the case of errors when making the prefix dirs.
+function mkdir (p, cb) {
+ mkdirp(p, function (er, made) {
+ // it could be that we couldn't create it, because it
+ // already exists, and is on a read-only fs.
+ if (er) {
+ return fs.stat(p, function (er2, st) {
+ if (er2 || !st.isDirectory()) return cb(er)
+ return cb(null, made)
+ })
+ }
+ return cb(er, made)
+ })
+}
+
npm.commands = {}
npm.ELIFECYCLE = {}
npm.E404 = {}
npm.EISGIT = {}
npm.ECYCLE = {}
npm.ENOTSUP = {}
-
-// HACK for windows
-if (process.platform === "win32") {
- // stub in unavailable methods from process and fs binding
- if (!process.getuid) process.getuid = function() {}
- if (!process.getgid) process.getgid = function() {}
- var fsBinding = process.binding("fs")
- if (!fsBinding.chown) fsBinding.chown = function() {
- var cb = arguments[arguments.length - 1]
- if (typeof cb == "function") cb()
- }
-
- // patch rename/renameSync, but this should really be fixed in node
- var _fsRename = fs.rename
- , _fsPathPatch
- _fsPathPatch = function(p) {
- return p && p.replace(/\\/g, "/") || p;
- }
- fs.rename = function(p1, p2) {
- arguments[0] = _fsPathPatch(p1)
- arguments[1] = _fsPathPatch(p2)
- return _fsRename.apply(fs, arguments);
- }
-}
+npm.EBADPLATFORM = {}
try {
// startup, ok to do this synchronously
, "unstar": "star" // same function
, "apihelp" : "help"
, "login": "adduser"
+ , "add-user": "adduser"
}
, aliasNames = Object.keys(aliases)
, "unpublish"
, "owner"
, "deprecate"
+ , "shrinkwrap"
, "help"
, "help-search"
})
// the prefix MUST exist, or else nothing works.
if (!npm.config.get("global")) {
- mkdir(p, npm.modes.exec, null, null, true, next)
+ mkdir(p, next)
} else {
next(er)
}
, enumerable : true
})
// the prefix MUST exist, or else nothing works.
- mkdir(gp, npm.modes.exec, null, null, true, next)
+ mkdir(gp, next)
})
var i = 2
, dir = path.resolve(p[0], "node_modules", dep)
, has = p[2]
, want = p[3]
+
+ // XXX add --json support
+ // Should match (more or less) the output of ls --json
+
if (parseable) {
var str = dir
if (npm.config.get("long")) {
function cleanBuild (folders, set, cb) {
// https://github.com/isaacs/npm/issues/1872
- // If there's a makefile, try 'make clean'
// If there's a wscript, try 'node-waf clean'
// But don't die on either of those if they fail.
// Just a best-effort kind of deal.
if (er) return cb(er)
if (files.indexOf("wscript") !== -1) {
exec("node-waf", ["clean"], null, false, f, thenBuild)
- } else if (files.indexOf("Makefile") !== -1) {
- exec("make", ["clean"], null, false, f, thenBuild)
} else thenBuild()
})
function thenBuild (er) {
, stdout = process.stdout
, cols = !tty.isatty(stdout.fd) ? Infinity
: stdout._handle ? stdout._handle.getWindowSize()[0]
- : tty.getWindowSize()[1]
+ : process.stdout.getWindowSize()[0]
+ cols = (cols == 0) ? Infinity : cols
} catch (ex) { cols = Infinity }
// name, desc, author, keywords
set.completion = npm.commands.config.completion
function set (args, cb) {
+ if (!args.length) return cb(set.usage)
npm.commands.config(["set"].concat(args), cb)
}
var readJson = require("./utils/read-json.js")
, rm = require("rimraf")
+ , gentlyRm = require("./utils/gently-rm.js")
, npm = require("./npm.js")
, path = require("path")
, fs = require("graceful-fs")
if (process.platform === "win32") {
rm(path.resolve(binRoot, b) + ".cmd", cb)
} else {
- rm( path.resolve(binRoot, b)
- , { gently: !npm.config.get("force") && folder }
- , cb )
+ gentlyRm( path.resolve(binRoot, b)
+ , !npm.config.get("force") && folder
+ , cb )
}
}, cb)
}
function rmMans (pkg, folder, parent, top, cb) {
- if (!pkg.man || !top || process.platform === "win32") return cb()
+ if (!pkg.man
+ || !top
+ || process.platform === "win32"
+ || !npm.config.get("global")) {
+ return cb()
+ }
var manRoot = path.resolve(npm.config.get("prefix"), "share", "man")
asyncMap(pkg.man, function (man, cb) {
var parseMan = man.match(/(.*)\.([0-9]+)(\.gz)?$/)
: pkg.name + "-" + bn)
+ "." + sxn + gz
)
- rm( manDest
- , { gently: !npm.config.get("force") && folder }
- , cb )
+ gentlyRm( manDest
+ , !npm.config.get("force") && folder
+ , cb )
}, cb)
}
function uninstall_ (args, nm, cb) {
asyncMap(args, function (arg, cb) {
- var p = path.resolve(nm, arg)
+ // uninstall .. should not delete /usr/local/lib/node_modules/..
+ var p = path.join(path.resolve(nm), path.join("/", arg))
+ if (path.resolve(p) === nm) {
+ log.warn(arg, "uninstall: invalid argument")
+ return cb(null, [])
+ }
fs.lstat(p, function (er) {
if (er) {
log.warn(arg, "Not installed in "+nm)
var fs = require("graceful-fs")
, chain = require("slide").chain
- , mkdir = require("./mkdir-p.js")
+ , mkdir = require("mkdirp")
, rm = require("rimraf")
, log = require("./log.js")
, path = require("path")
target = ""
shTarget = ""
} else {
- longProg = "\"%~dp0\"\\\"" + prog + ".exe\""
+ longProg = "\"%~dp0\\" + prog + ".exe\""
shLongProg = "\"`dirname \"$0\"`/" + prog + "\""
target = "\"%~dp0\\" + target + "\""
shTarget = "\"`dirname \"$0\"`/" + shTarget + "\""
}
- // @IF EXIST "%~dp0"\"node.exe" (
+ // @IF EXIST "%~dp0\node.exe" (
// "%~dp0\node.exe" "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*
// ) ELSE (
- // node "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*
+ // node "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*
// )
var cmd
if (longProg) {
module.exports = fileCompletion
var find = require("../find.js")
- , mkdir = require("../mkdir-p.js")
+ , mkdir = require("mkdirp")
, path = require("path")
function fileCompletion (root, req, depth, cb) {
, os = require("os")
, nopt = require("nopt")
, log = require("./log.js")
+ , npm = require("../npm.js")
function Octal () {}
function validateOctal (data, k, val) {
, cache : process.platform === "win32"
? path.resolve(process.env.APPDATA || home || temp, "npm-cache")
: path.resolve( home || temp, ".npm")
+ , "cache-max": Infinity
+ , "cache-min": 0
, color : process.platform !== "win32" || winColor
, coverage: false
, "init.author.name" : ""
, "init.author.email" : ""
, "init.author.url" : ""
+ , json: false
, link: false
, logfd : 2
, loglevel : "http"
, proxy : process.env.HTTP_PROXY || process.env.http_proxy || null
, "https-proxy" : process.env.HTTPS_PROXY || process.env.https_proxy ||
process.env.HTTP_PROXY || process.env.http_proxy || null
+ , "user-agent" : "npm/" + npm.version + " node/" + process.version
, "rebuild-bundle" : true
, registry : "http" + (httpsOk ? "s" : "") + "://registry.npmjs.org/"
, rollback : true
, save : false
+ , "save-dev" : false
+ , "save-optional" : false
, searchopts: ""
, searchexclude: null
, searchsort: "name"
, userignorefile : path.resolve(home, ".npmignore")
, umask: 022
, version : false
+ , versions : false
, viewer: process.platform === "win32" ? "browser" : "man"
, yes: null
, browser : String
, ca: [null, String]
, cache : path
+ , "cache-max": Number
+ , "cache-min": Number
, color : ["always", Boolean]
, coverage: Boolean
, depth : Number
, globalignorefile: path
, group : [Number, String]
, "https-proxy" : [null, url]
+ , "user-agent" : String
, ignore : String
, "init.version" : [null, semver]
, "init.author.name" : String
, "init.author.email" : String
, "init.author.url" : ["", url]
+ , json: Boolean
, link: Boolean
, logfd : [Number, Stream]
, loglevel : ["silent","win","error","warn","http","info","verbose","silly"]
, registry : [null, url]
, rollback : Boolean
, save : Boolean
+ , "save-dev" : Boolean
+ , "save-optional" : Boolean
, searchopts : String
, searchexclude: [null, String]
, searchsort: [ "name", "-name"
, userignorefile : path
, umask: Octal
, version : Boolean
+ , versions : Boolean
, viewer: String
, yes: [false, null, Boolean]
, _exit : Boolean
, porcelain : ["--parseable"]
, g : ["--global"]
, S : ["--save"]
+ , D : ["--save-dev"]
+ , O : ["--save-optional"]
, y : ["--yes"]
, n : ["--no-yes"]
}
].join("\n"))
break
+ case npm.EBADPLATFORM:
+ er.code = "EBADPLATFORM"
+ log.error([er.message
+ ,"Not compatible with your operating system or architecture: "+er.pkgid
+ ,"Valid OS: "+er.os.join(",")
+ ,"Valid Arch: "+er.cpu.join(",")
+ ,"Actual OS: "+process.platform
+ ,"Actual Arch: "+process.arch
+ ].join("\n"))
+ break
+
case "EEXIST":
case constants.EEXIST:
log.error([er.message
+++ /dev/null
-// build up a set of exclude lists in order of precedence:
-// [ ["!foo", "bar"]
-// , ["foo", "!bar"] ]
-// being *included* will override a previous exclusion,
-// and being excluded will override a previous inclusion.
-//
-// Each time the tar file-list generator thingie enters a new directory,
-// it calls "addIgnoreFile(dir, list, cb)". If an ignore file is found,
-// then it is added to the list and the cb() is called with an
-// child of the original list, so that we don't have
-// to worry about popping it off at the right time, since other
-// directories will continue to use the original parent list.
-//
-// If no ignore file is found, then the original list is returned.
-//
-// To start off with, ~/.{npm,git}ignore is added, as is
-// prefix/{npm,git}ignore, effectively treated as if they were in the
-// base package directory.
-
-exports.addIgnoreFile = addIgnoreFile
-exports.readIgnoreFile = readIgnoreFile
-exports.parseIgnoreFile = parseIgnoreFile
-exports.test = test
-exports.filter = filter
-
-var path = require("path")
- , fs = require("graceful-fs")
- , minimatch = require("minimatch")
- , relativize = require("./relativize.js")
- , log = require("./log.js")
-
-// todo: memoize
-
-// read an ignore file, or fall back to the
-// "gitBase" file in the same directory.
-function readIgnoreFile (file, gitBase, cb) {
- //log.warn(file, "ignoreFile")
- if (!file) return cb(null, "")
- fs.readFile(file, function (er, data) {
- if (!er || !gitBase) return cb(null, data || "")
- var gitFile = path.resolve(path.dirname(file), gitBase)
- fs.readFile(gitFile, function (er, data) {
- return cb(null, data || "")
- })
- })
-}
-
-// read a file, and then return the list of patterns
-function parseIgnoreFile (file, gitBase, dir, cb) {
- readIgnoreFile(file, gitBase, function (er, data) {
- data = data ? data.toString("utf8") : ""
-
- data = data.split(/[\r\n]+/).map(function (p) {
- return p.trim()
- }).filter(function (p) {
- return p.length && p.charAt(0) !== "#"
- })
- data.dir = dir
- return cb(er, data)
- })
-}
-
-// add an ignore file to an existing list which can
-// then be passed to the test() function. If the ignore
-// file doesn't exist, then the list is unmodified. If
-// it is, then a concat-child of the original is returned,
-// so that this is suitable for walking a directory tree.
-function addIgnoreFile (file, gitBase, list, dir, cb) {
- if (typeof cb !== "function") cb = dir, dir = path.dirname(file)
- if (typeof cb !== "function") cb = list, list = []
- parseIgnoreFile(file, gitBase, dir, function (er, data) {
- if (!er && data) {
- // package.json "files" array trumps everything
- // Make sure it's always last.
- if (list.length && list[list.length-1].packageFiles) {
- list = list.concat([data, list.pop()])
- } else {
- list = list.concat([data])
- }
- }
- cb(er, list)
- })
-}
-
-
-// no IO
-// loop through the lists created in the functions above, and test to
-// see if a file should be included or not, given those exclude lists.
-function test (file, excludeList) {
- if (path.basename(file) === "package.json") return true
- // log.warn(file, "test file")
- // log.warn(excludeList, "test list")
- var incRe = /^\!(\!\!)*/
- , excluded = false
- for (var i = 0, l = excludeList.length; i < l; i ++) {
- var excludes = excludeList[i]
- , dir = excludes.dir
-
- // chop the filename down to be relative to excludeDir
- var rf = relativize(file, dir, true)
- rf = rf.replace(/^\.?\//, "")
- if (file.slice(-1) === "/") rf += "/"
-
- // log.warn([file, rf], "rf")
-
- for (var ii = 0, ll = excludes.length; ii < ll; ii ++) {
- var ex = excludes[ii].replace(/^(!*)\//, "$1")
- , inc = !!ex.match(incRe)
-
- // log.warn([ex, rf], "ex, rf")
- // excluding/including a dir excludes/includes all the files in it.
- if (ex.slice(-1) === "/") ex += "**"
-
- // if this is not an inclusion attempt, and someone else
- // excluded it, then just continue, because there's nothing
- // that can be done here to change the exclusion.
- if (!inc && excluded) continue
-
- // if it's an inclusion attempt, and the file has not been
- // excluded, then skip it, because there's no need to try again.
- if (inc && !excluded) continue
-
- // if it matches the pattern, then it should be excluded.
- excluded = !!minimatch(rf, ex, { matchBase: true })
- // log.error([rf, ex, excluded], "rf, ex, excluded")
-
- // if you include foo, then it also includes foo/bar.js
- if (inc && excluded && ex.slice(-3) !== "/**") {
- excluded = minimatch(rf, ex + "/**", { matchBase: true })
- // log.warn([rf, ex + "/**", inc, excluded], "dir without /")
- }
-
- // if you exclude foo, then it also excludes foo/bar.js
- if (!inc
- && excluded
- && ex.slice(-3) !== "/**"
- && rf.slice(-1) === "/"
- && excludes.indexOf(ex + "/**") === -1) {
- // log.warn(ex + "/**", "adding dir-matching exclude pattern")
- excludes.splice(ii, 1, ex, ex + "/**")
- ll ++
- }
- }
- // log.warn([rf, excluded, excludes], "rf, excluded, excludes")
- }
- // true if it *should* be included
- // log.warn([file, excludeList, excluded], "file, excluded")
- return !excluded
-}
-
-// returns a function suitable for Array#filter
-function filter (dir, list) { return function (file) {
- file = file.trim()
- var testFile = path.resolve(dir, file)
- if (file.slice(-1) === "/") testFile += "/"
- return file && test(testFile, list)
-}}
-
module.exports = exec
exec.spawn = spawn
exec.pipe = pipe
, myGID = process.getgid ? process.getgid() : null
, isRoot = process.getuid && myUID === 0
, constants = require("constants")
+ , uidNumber = require("uid-number")
function exec (cmd, args, env, takeOver, cwd, uid, gid, cb) {
if (typeof cb !== "function") cb = gid, gid = null
log.verbose(uid, "Setting uid from "+myUID)
log.verbose(new Error().stack, "stack at uid setting")
}
+
+ if (uid && gid && (isNaN(uid) || isNaN(gid))) {
+ // get the numeric values
+ return uidNumber(uid, gid, function (er, uid, gid) {
+ if (er) return cb(er)
+ exec(cmd, args, env, takeOver, cwd, uid, gid, cb)
+ })
+ }
+
log.silly(cmd+" "+args.map(JSON.stringify).join(" "), "exec")
var stdout = ""
, stderr = ""
cb(errState = new Error(
"Failed "+(cp1.name || "<unknown>")+"\nexited with "+code))
})
+
cp2.on("exit", function (code) {
cp2._exited = true
if (errState) return
, env : env || process.env
, cwd : cwd || null }
, cp
- if (uid != null) opts.uid = uid
- if (gid != null) opts.gid = gid
- if (!isNaN(opts.uid)) opts.uid = +opts.uid
- if (!isNaN(opts.gid)) opts.gid = +opts.gid
+
+ if (uid && !isNaN(uid)) opts.uid = +uid
+ if (gid && !isNaN(gid)) opts.gid = +gid
+
var name = c +" "+ a.map(JSON.stringify).join(" ")
log.silly([c, a, opts.cwd], "spawning")
cp = child_process.spawn(c, a, opts)
, url = require("url")
, log = require("./log.js")
, path = require("path")
- , mkdir = require("./mkdir-p.js")
+ , mkdir = require("mkdirp")
+ , chownr = require("chownr")
, regHost
- , getAgent = require("./get-agent.js")
module.exports = fetch
function fetch (remote, local, headers, cb) {
if (typeof cb !== "function") cb = headers, headers = {}
log.verbose(local, "fetch to")
- mkdir(path.dirname(local), function (er) {
+ mkdir(path.dirname(local), function (er, made) {
if (er) return cb(er)
fetch_(remote, local, headers, cb)
})
request({ url: remote
, proxy: proxy
- , agent: getAgent(remote)
, strictSSL: npm.config.get("strict-ssl")
+ , ca: remote.host === regHost ? npm.config.get("ca") : undefined
+ , headers: { "user-agent": npm.config.get("user-agent") }
, onResponse: onResponse }).pipe(fstr)
function onResponse (er, res) {
if (er) return fstr.emit("error", er)
return cb(null, p)
}
- return findPrefix_(path.dirname(p), original, cb)
+ var d = path.dirname(p)
+ if (d === p) return cb(null, original)
+
+ return findPrefix_(d, original, cb)
})
}
+++ /dev/null
-// get an http/https agent
-// This is necessary for the custom CA certs in http2,
-// especially while juggling multiple different registries.
-//
-// When using http2, the agent key is just the CA setting,
-// since it can manage socket pooling across different host:port
-// options. When using the older implementation, the
-// key is ca:host:port combination.
-
-module.exports = getAgent
-
-var npm = require("../npm.js")
- , url = require("url")
- , agents = {}
- , isHttp2 = !!require("http").globalAgent
- , registry = url.parse(npm.config.get("registry") || "")
- , regCA = npm.config.get("ca")
-
-function getAgent (remote) {
- // If not doing https, then there's no CA cert to manage.
- // on http2, this will use the default global agent.
- // on http1, this is undefined, so it'll spawn based on
- // host:port if necessary.
- if (remote.protocol !== "https:") {
- return require("http").globalAgent
- }
-
- if (typeof remote === "string") {
- remote = url.parse(remote)
- }
-
- var ca
- // if this is the registry, then use the configuration ca.
- // otherwise, just use the built-in CAs that node has.
- // todo: multi-registry support.
- if (remote.hostname === registry.hostname
- && remote.port === registry.port) {
- ca = regCA
- }
-
- // no CA, just use the default agent.
- if (!ca) {
- return require("https").globalAgent
- }
-
- var hostname = remote.hostname
- , port = remote.port
- , key = agentKey(hostname, port, ca)
-
- return agents[key] = agents[key] || getAgent_(hostname, port, ca)
-}
-
-function getAgent_ (hostname, port, ca) {
- var Agent = require("https").Agent
- return new Agent({ host: hostname
- , port: port
- , ca: ca })
-}
-
-function agentKey (hostname, port, ca) {
- return JSON.stringify(isHttp2 ? ca : [hostname, port, ca])
-}
+++ /dev/null
-
-module.exports = get
-function get (obj, key) {
- for (var i in obj) if (i.toLowerCase() === key.toLowerCase()) return obj[i]
- return undefined
-}
if (typeof f !== "string" || !f) return f
// replace any ${ENV} values with the appropriate environ.
- return f.replace(/\$\{([^}]+)\}/g, function (orig, name, i, s) {
- return process.env[name] || orig
+ var envExpr = /(\\*)\$\{([^}]+)\}/g
+ return f.replace(envExpr, function (orig, esc, name, i, s) {
+ esc = esc.length && esc.length % 2
+ if (esc) return orig
+ if (undefined === process.env[name]) {
+ throw new Error("Failed to replace env in config: "+orig)
+ }
+ return process.env[name]
})
}
, chain = require("slide").chain
, constants = require("constants")
, output = require("./output.js")
+ , PATH = "PATH"
+
+// windows calls it's path "Path" usually, but this is not guaranteed.
+if (process.platform === "win32") {
+ PATH = "Path"
+ Object.keys(process.env).forEach(function (e) {
+ if (e.match(/^PATH$/i)) {
+ PATH = e
+ }
+ })
+}
function lifecycle (pkg, stage, wd, unsafe, failOk, cb) {
if (typeof cb !== "function") cb = failOk, failOk = false
}
function lifecycle_ (pkg, stage, wd, env, unsafe, failOk, cb) {
- var PATH = []
+ var pathArr = []
, p = wd.split("node_modules")
, acc = path.resolve(p.shift())
p.forEach(function (pp) {
- PATH.unshift(path.join(acc, "node_modules", ".bin"))
+ pathArr.unshift(path.join(acc, "node_modules", ".bin"))
acc = path.join(acc, "node_modules", pp)
})
- PATH.unshift(path.join(acc, "node_modules", ".bin"))
- if (env.PATH) PATH.push(env.PATH)
- env.PATH = PATH.join(process.platform === "win32" ? ";" : ":")
+ pathArr.unshift(path.join(acc, "node_modules", ".bin"))
+
+ // we also unshift the bundled node-gyp-bin folder so that
+ // the bundled one will be used for installing things.
+ pathArr.unshift(path.join(__dirname, "..", "..", "bin", "node-gyp-bin"))
+
+ if (env[PATH]) pathArr.push(env[PATH])
+ env[PATH] = pathArr.join(process.platform === "win32" ? ";" : ":")
var packageLifecycle = pkg.scripts && pkg.scripts.hasOwnProperty(stage)
, cmd = env.npm_lifecycle_script
, sh = "sh"
, shFlag = "-c"
-
+
if (process.platform === "win32") {
sh = "cmd"
shFlag = "/c"
log.verbose(unsafe, "unsafe-perm in lifecycle")
- output.write("\n> "+pkg._id+" " + stage+" "+wd+"\n> "+cmd+"\n", function (er) {
+ var note = "\n> " + pkg._id + " " + stage + " " + wd
+ + "\n> " + cmd + "\n"
+
+ output.write(note, function (er) {
if (er) return cb(er)
-
+
exec( sh, [shFlag, cmd], env, true, wd
, user, group
, function (er, code, stdout, stderr) {
return
}
var value = ini.get(i)
+ if (/^(log|out)fd$/.test(i) && typeof value === "object") {
+ // not an fd, a stream
+ return
+ }
if (!value) value = ""
else if (typeof value !== "string") value = JSON.stringify(value)
var fs = require("graceful-fs")
, chain = require("slide").chain
- , mkdir = require("./mkdir-p.js")
- , rm = require("rimraf")
+ , mkdir = require("mkdirp")
+ , rm = require("./gently-rm.js")
, log = require("./log.js")
, path = require("path")
, relativize = require("./relativize.js")
if (npm.config.get("force")) gently = false
chain
( [ [fs, "stat", from]
- , [rm, to, { gently: gently }]
+ , [rm, to, gently]
, [mkdir, path.dirname(to)]
, [fs, "symlink", relativize(from, to), to] ]
, cb)
+++ /dev/null
-
-var log = require("./log.js")
- , fs = require("graceful-fs")
- , path = require("path")
- , npm = require("../npm.js")
- , exec = require("./exec.js")
- , uidNumber = require("./uid-number.js")
- , umask = process.umask()
- , umaskOrig = umask
- , addedUmaskExit = false
- , mkdirCache = {}
-
-module.exports = mkdir
-function mkdir (ensure, mode, uid, gid, noChmod, cb_) {
- if (typeof cb_ !== "function") cb_ = noChmod, noChmod = null
- if (typeof cb_ !== "function") cb_ = gid, gid = null
- if (typeof cb_ !== "function") cb_ = uid, uid = null
- if (typeof cb_ !== "function") cb_ = mode, mode = npm.modes.exec
-
- if (mode & umask) {
- log.verbose(mode.toString(8), "umasking from "+umask.toString(8))
- process.umask(umask = 0)
- if (!addedUmaskExit) {
- addedUmaskExit = true
- process.on("exit", function () { process.umask(umask = umaskOrig) })
- }
- }
-
- ensure = path.resolve(ensure).replace(/\/+$/, '')
-
- // mkdir("/") should not do anything, since that always exists.
- if (!ensure
- || ( process.platform === "win32"
- && ensure.match(/^[a-zA-Z]:(\\|\/)?$/))) {
- return cb_()
- }
-
- if (mkdirCache.hasOwnProperty(ensure)) {
- return mkdirCache[ensure].push(cb_)
- }
- mkdirCache[ensure] = [cb_]
-
- function cb (er) {
- var cbs = mkdirCache[ensure]
- delete mkdirCache[ensure]
- cbs.forEach(function (c) { c(er) })
- }
-
- if (uid === null && gid === null) {
- return mkdir_(ensure, mode, uid, gid, noChmod, cb)
- }
-
- uidNumber(uid, gid, function (er, uid, gid) {
- if (er) return cb(er)
- mkdir_(ensure, mode, uid, gid, noChmod, cb)
- })
-}
-
-function mkdir_ (ensure, mode, uid, gid, noChmod, cb) {
- // if it's already a dir, then just check the bits and owner.
- fs.stat(ensure, function (er, s) {
- if (s && s.isDirectory()) {
- // check mode, uid, and gid.
- if ((noChmod || (s.mode & mode) === mode)
- && (typeof uid !== "number" || s.uid === uid)
- && (typeof gid !== "number" || s.gid === gid)) return cb()
- return done(ensure, mode, uid, gid, noChmod, cb)
- }
- return walkDirs(ensure, mode, uid, gid, noChmod, cb)
- })
-}
-
-function done (ensure, mode, uid, gid, noChmod, cb) {
- // now the directory has been created.
- // chown it to the desired uid/gid
- // Don't chown the npm.root dir, though, in case we're
- // in unsafe-perm mode.
- log.verbose("done: "+ensure+" "+mode.toString(8), "mkdir")
-
- // only chmod if noChmod isn't set.
- var d = done_(ensure, mode, uid, gid, cb)
- if (noChmod) return d()
- fs.chmod(ensure, mode, d)
-}
-
-function done_ (ensure, mode, uid, gid, cb) {
- return function (er) {
- if (er
- || ensure === npm.dir
- || typeof uid !== "number"
- || typeof gid !== "number"
- || npm.config.get("unsafe-perm")) return cb(er)
- uid = Math.floor(uid)
- gid = Math.floor(gid)
- fs.chown(ensure, uid, gid, cb)
- }
-}
-
-var pathSplit = process.platform === "win32" ? /\/|\\/ : "/"
-function walkDirs (ensure, mode, uid, gid, noChmod, cb) {
- var dirs = ensure.split(pathSplit)
- , walker = []
- , foundUID = null
- , foundGID = null
-
- // gobble the "/" or C: first
- walker.push(dirs.shift())
-
- // The loop that goes through and stats each dir.
- ;(function S (d) {
- // no more directory steps left.
- if (d === undefined) {
- // do the chown stuff
- return done(ensure, mode, uid, gid, noChmod, cb)
- }
-
- // get the absolute dir for the next piece being stat'd
- walker.push(d)
- var dir = walker.join(path.SPLIT_CHAR)
-
- // stat callback lambda
- fs.stat(dir, function STATCB (er, s) {
- if (er) {
- // the stat failed - directory does not exist.
-
- log.verbose(er.message, "mkdir (expected) error")
-
- // use the same uid/gid as the nearest parent, if not set.
- if (foundUID !== null) uid = foundUID
- if (foundGID !== null) gid = foundGID
-
- // make the directory
- fs.mkdir(dir, mode, function MKDIRCB (er) {
- // since stat and mkdir are done as two separate syscalls,
- // operating on a path rather than a file descriptor, it's
- // possible that the directory didn't exist when we did
- // the stat, but then *did* exist when we go to to the mkdir.
- // If we didn't care about uid/gid, we could just mkdir
- // repeatedly, failing on any error other than "EEXIST".
- if (er && er.message.indexOf("EEXIST") === 0) {
- return fs.stat(dir, STATCB)
- }
-
- // any other kind of error is not saveable.
- if (er) return cb(er)
-
- // at this point, we've just created a new directory successfully.
-
- // if we care about permissions
- if (!npm.config.get("unsafe-perm") // care about permissions
- // specified a uid and gid
- && uid !== null
- && gid !== null ) {
- // set the proper ownership
- return fs.chown(dir, uid, gid, function (er) {
- if (er) return cb(er)
- // attack the next portion of the path.
- S(dirs.shift())
- })
- } else {
- // either we don't care about ownership, or it's already right.
- S(dirs.shift())
- }
- }) // mkdir
-
- } else {
- // the stat succeeded.
- if (s.isDirectory()) {
- // if it's a directory, that's good.
- // if the uid and gid aren't already set, then try to preserve
- // the ownership on up the tree. Things in ~ remain owned by
- // the user, things in / remain owned by root, etc.
- if (uid === null && typeof s.uid === "number") foundUID = s.uid
- if (gid === null && typeof s.gid === "number") foundGID = s.gid
-
- // move onto next portion of path
- S(dirs.shift())
-
- } else {
- // the stat succeeded, but it's not a directory
- log.verbose(dir, "mkdir exists")
- log.silly(s, "stat("+dir+")")
- log.verbose(s.isDirectory(), "isDirectory()")
- cb(new Error("Failed to mkdir "+dir+": File exists"))
- }// if (isDirectory) else
- } // if (stat failed) else
- }) // stat
-
- // start the S function with the first item in the list of directories.
- })(dirs.shift())
-}
, npm = require("../../npm.js")
, path = require("path")
, log = require("../log.js")
- , mkdir = require("../mkdir-p.js")
+ , mkdir = require("mkdirp")
, cacheStat = null
+ , chownr = require("chownr")
function get (project, version, timeout, nofollow, staleOk, cb) {
if (typeof cb !== "function") cb = staleOk, staleOk = false
throw new Error("No callback provided to registry.get")
}
+ timeout = Math.min(timeout, npm.config.get("cache-max"))
+ timeout = Math.max(timeout, npm.config.get("cache-min"))
+
if ( process.env.COMP_CWORD !== undefined
&& process.env.COMP_LINE !== undefined
&& process.env.COMP_POINT !== undefined
data = remoteData
if (!data) {
- er = new Error("failed to fetch from registry: " + uri)
+ er = er || new Error("failed to fetch from registry: " + uri)
}
if (er) return cb(er, data, raw, response)
}
function saveToCache_ (cache, data, uid, gid, saved) {
- mkdir(path.dirname(cache), npm.modes.exec, uid, gid, function (er) {
+ mkdir(path.dirname(cache), function (er, made) {
if (er) return saved()
fs.writeFile(cache, JSON.stringify(data), function (er) {
if (er || uid === null || gid === null) {
return saved()
}
- fs.chown(cache, uid, gid, saved)
+ chownr(made || cache, uid, gid, saved)
})
})
}
, stream = require("stream")
, Stream = stream.Stream
, request = require("request")
- , getAgent = require("../get-agent.js")
function regRequest (method, where, what, etag, nofollow, cb_) {
if (typeof cb_ !== "function") cb_ = nofollow, nofollow = false
function makeRequest (method, remote, where, what, etag, nofollow, cb) {
var opts = { url: remote
, method: method
- , agent: getAgent(remote)
+ , ca: npm.config.get("ca")
, strictSSL: npm.config.get("strict-ssl") }
, headers = opts.headers = {}
if (etag) {
headers.accept = "application/json"
+ headers["user-agent"] = npm.config.get("user-agent")
+
opts.proxy = npm.config.get( remote.protocol === "https:"
? "https-proxy" : "proxy" )
if (!npm.config.get("unicode")) {
arg = arg.replace(/â””/g, "`")
.replace(/─/g, "-")
+ .replace(/│/g, "|")
.replace(/├/g, "+")
.replace(/┬/g, "-")
}
, semver = require("semver")
, readJson = require("./read-json.js")
, log = require("./log.js")
+ , url = require("url")
module.exports = readInstalled
})
readJson(path.resolve(folder, "package.json"), function (er, data) {
- obj = data
+ obj = copy(data)
+
if (!parent) {
obj = obj || true
er = null
continue
}
if ( typeof deps[d] === "string"
+ // url deps presumed innocent.
+ && !url.parse(deps[d]).protocol
&& !semver.satisfies(found.version, deps[d])) {
// the bad thing will happen
log.warn(obj.path + " requires "+d+"@'"+deps[d]
return obj
}
+function copy (obj) {
+ if (!obj || typeof obj !== 'object') return obj
+ if (Array.isArray(obj)) return obj.map(copy)
+
+ var o = {}
+ for (var i in obj) o[i] = copy(obj[i])
+ return o
+}
+
if (module === require.main) {
var util = require("util")
console.error("testing")
var wscript = null
, contributors = null
, serverjs = null
+ , gypfile = null
- if (opts.wscript != null) {
+ if (opts.gypfile !== null && opts.gypfile !== undefined) {
+ gypfile = opts.gypfile
+ next()
+ } else {
+ var pkgdir = path.dirname(jsonFile)
+
+ function hasGyp (has) {
+ gypfile = opts.gypfile = has
+ next()
+ }
+
+ fs.readdir(pkgdir, function (er, gf) {
+ // this would be weird.
+ if (er) return hasGyp(false)
+
+ // see if there are any *.gyp files in there.
+ gf = gf.filter(function (f) {
+ return f.match(/\.gyp$/)
+ })
+ gf = gf[0]
+ return hasGyp(!!gf)
+ })
+ }
+
+ if (opts.wscript !== null && opts.wscript !== undefined) {
wscript = opts.wscript
next()
} else fs.readFile( path.join(path.dirname(jsonFile), "wscript")
next()
})
- if (opts.contributors != null) {
+ if (opts.contributors !== null && opts.contributors !== undefined) {
contributors = opts.contributors
next()
} else fs.readFile( path.join(path.dirname(jsonFile), "AUTHORS")
next()
})
- if (opts.serverjs != null) {
+ if (opts.serverjs !== null && opts.serverjs !== undefined) {
serverjs = opts.serverjs
next()
} else fs.stat( path.join(path.dirname(jsonFile), "server.js")
})
function next () {
- if (wscript === null
- || contributors === null
- || serverjs === null) {
+ if (wscript === null ||
+ contributors === null ||
+ gypfile === null ||
+ serverjs === null) {
return
}
- fs.readFile(jsonFile, processJson(opts, function (er, data) {
+ // XXX this api here is insane. being internal is no excuse.
+ // please refactor.
+ var thenLoad = processJson(opts, function (er, data) {
if (er) return cb(er)
var doLoad = !(jsonFile.indexOf(npm.cache) === 0 &&
path.basename(path.dirname(jsonFile)) !== "package")
if (!doLoad) return cb(er, data)
loadPackageDefaults(data, path.dirname(jsonFile), cb)
- }))
+ })
+
+ fs.readFile(jsonFile, function (er, data) {
+ if (er && er.code === "ENOENT") {
+ // single-file module, maybe?
+ // check index.js for a /**package { ... } **/ section.
+ var indexFile = path.resolve(path.dirname(jsonFile), "index.js")
+ return fs.readFile(indexFile, function (er2, data) {
+ // if this doesn't work, then die with the original error.
+ if (er2) return cb(er)
+ data = parseIndex(data)
+ if (!data) return cb(er)
+ thenLoad(null, data)
+ })
+ }
+ thenLoad(er, data)
+ })
}
}
+// sync. no io.
+// /**package { "name": "foo", "version": "1.2.3", ... } **/
+function parseIndex (data) {
+ data = data.toString()
+ data = data.split(/^\/\*\*package(?:\s|$)/m)
+ if (data.length < 2) return null
+ data = data[1]
+ data = data.split(/\*\*\/$/m)
+ if (data.length < 2) return null
+ data = data[0]
+ data = data.replace(/^\s*\*/mg, "")
+ return data
+}
+
function processJson (opts, cb) {
if (typeof cb !== "function") cb = opts, opts = {}
if (typeof cb !== "function") {
}
function processJsonString (opts, cb) { return function (er, jsonString) {
- jsonString += ""
if (er) return cb(er, jsonString)
+ jsonString += ""
var json
try {
json = JSON.parse(jsonString)
}
if (typeof json.bugs === "object") {
+ // just go ahead and correct these.
Object.keys(bugsTypos).forEach(function (d) {
if (json.bugs.hasOwnProperty(d)) {
- log.warn( "package.json: bugs['" + d + "'] should probably be "
- + "bugs['" + bugsTypos[d] + "']", json._id)
- }
+ json.bugs[ bugsTypos[d] ] = json.bugs[d]
+ delete json.bugs[d]
+ }
})
}
var scripts = json.scripts || {}
+ // if it has a bindings.gyp, then build with node-gyp
+ if (opts.gypfile && !json.prebuilt) {
+ log.verbose([json.prebuilt, opts], "has bindings.gyp")
+ if (!scripts.install && !scripts.preinstall) {
+ scripts.install = "node-gyp rebuild"
+ json.scripts = scripts
+ }
+ }
+
// if it has a wscript, then build it.
if (opts.wscript && !json.prebuilt) {
log.verbose([json.prebuilt, opts], "has wscript")
if (opts.dev
|| npm.config.get("dev")
|| npm.config.get("npat")) {
- // log.warn(json._id, "Adding devdeps")
Object.keys(json.devDependencies || {}).forEach(function (d) {
json.dependencies[d] = json.devDependencies[d]
})
- // log.warn(json.dependencies, "Added devdeps")
}
typoWarn(json)
var depObjectifyWarn = {}
function depObjectify (deps, d, id) {
- if ((!deps || typeof deps !== "object" || Array.isArray(deps))
- && !depObjectifyWarn[id+d]) {
- log.warn( d + " field should be hash of <name>:<version-range> pairs"
- , id )
- depObjectifyWarn[id + d] = true
- }
-
if (!deps) return {}
if (typeof deps === "string") {
deps = deps.trim().split(/[\n\r\s\t ,]+/)
+++ /dev/null
-
-module.exports = set
-var get = require("./get.js")
- , processJson = require("./read-json.js").processJson
-function set (obj, key, val) {
- for (var i in obj) {
- if (i.toLowerCase() === key.toLowerCase()) return obj[i] = val
- }
- obj[key] = val
- if (!val) return
- // if it's a package set, then assign all the versions.
- if (val.versions) return Object.keys(val.versions).forEach(function (v) {
- if (typeof val.versions[v] !== "object") return
- set(obj, key+"@"+v, val.versions[v])
- })
- // Note that this doesn't put the dist-tags there, only updates the versions
- if (key === val.name+"@"+val.version) {
- processJson(val)
- var reg = get(obj, val.name) || {}
- reg.name = reg._id = val.name
- set(obj, val.name, reg)
- reg.versions = get(reg, "versions") || {}
- if (!get(reg.versions, val.version)) set(reg.versions, val.version, val)
- }
-}
-// XXX lib/cache.js and this file need to be rewritten.
-
// commands for packing and unpacking tarballs
// this file is used by lib/cache.js
var npm = require("../npm.js")
, fs = require("graceful-fs")
- , exec = require("./exec.js")
- , find = require("./find.js")
- , mkdir = require("./mkdir-p.js")
- , asyncMap = require("slide").asyncMap
, path = require("path")
, log = require("./log.js")
- , uidNumber = require("./uid-number.js")
+ , uidNumber = require("uid-number")
, rm = require("rimraf")
, readJson = require("./read-json.js")
, relativize = require("./relativize.js")
, cache = require("../cache.js")
- , excludes = require("./excludes.js")
, myUid = process.getuid && process.getuid()
, myGid = process.getgid && process.getgid()
, tar = require("tar")
, zlib = require("zlib")
, fstream = require("fstream")
+ , Packer = require("fstream-npm")
+
+if (process.env.SUDO_UID && myUid === 0) {
+ if (!isNaN(process.env.SUDO_UID)) myUid = +process.env.SUDO_UID
+ if (!isNaN(process.env.SUDO_GID)) myGid = +process.env.SUDO_GID
+}
exports.pack = pack
exports.unpack = unpack
-exports.makeList = makeList
function pack (targetTarball, folder, pkg, dfc, cb) {
+ log.verbose([targetTarball, folder], "tar.pack")
if (typeof cb !== "function") cb = dfc, dfc = true
- folder = path.resolve(folder)
-
- log.verbose(folder, "pack")
-
- if (typeof pkg === "function") {
- cb = pkg, pkg = null
- return readJson(path.resolve(folder, "package.json"), function (er, pkg) {
- if (er) return log.er(cb, "Couldn't find package.json in "+folder)(er)
- pack(targetTarball, folder, pkg, dfc, cb)
- })
- }
- log.verbose(folder+" "+targetTarball, "pack")
- var parent = path.dirname(folder)
- , addFolder = path.basename(folder)
-
- var confEx = npm.config.get("ignore")
- log.silly(folder, "makeList")
- makeList(folder, pkg, dfc, function (er, files, cleanup) {
- if (er) return cb(er)
- // log.silly(files, "files")
- return packFiles(targetTarball, parent, files, pkg, function (er) {
- if (!cleanup || !cleanup.length) return cb(er)
- // try to be a good citizen, even/especially in the event of failure.
- cleanupResolveLinkDep(cleanup, function (er2) {
- if (er || er2) {
- if (er) log(er, "packing tarball")
- if (er2) log(er2, "while cleaning up resolved deps")
- }
- return cb(er || er2)
- })
- })
- })
-}
-
-function packFiles (targetTarball, parent, files, pkg, cb_) {
-
- var p
-
- files = files.map(function (f) {
- p = f.split(/\/|\\/)[0]
- return path.resolve(parent, f)
- })
-
- parent = path.resolve(parent, p)
-
- var called = false
- function cb (er) {
- if (called) return
- called = true
- cb_(er)
- }
log.verbose(targetTarball, "tarball")
- log.verbose(parent, "parent")
- fstream.Reader({ type: "Directory"
- , path: parent
- , filter: function () {
- // files should *always* get into tarballs
- // in a user-writable state, even if they're
- // being installed from some wackey vm-mounted
- // read-only filesystem.
- this.props.mode = this.props.mode | 0200
- var inc = -1 !== files.indexOf(this.path)
+ log.verbose(folder, "folder")
+ new Packer({ path: folder, type: "Directory", isDirectory: true })
+ .on("error", log.er(cb, "error reading "+folder))
- // WARNING! Hackety hack!
- // XXX Fix this in a better way.
- // Rename .gitignore to .npmignore if there is not a
- // .npmignore file there already, the better to lock
- // down installed packages with git for deployment.
- if (this.basename === ".gitignore") {
- if (this.parent._entries.indexOf(".npmignore") !== -1) {
- return false
- }
- var d = path.dirname(this.path)
- this.basename = ".npmignore"
- this.path = path.join(d, ".npmignore")
- }
- return inc
- }
- })
- .on("error", log.er(cb, "error reading "+parent))
// By default, npm includes some proprietary attributes in the
// package tarball. This is sane, and allowed by the spec.
// However, npm *itself* excludes these from its own package,
.on("error", log.er(cb, "gzip error "+targetTarball))
.pipe(fstream.Writer({ type: "File", path: targetTarball }))
.on("error", log.er(cb, "Could not write "+targetTarball))
- .on("close", cb)
+ .on("close", function () {
+ cb()
+ })
}
function unpack (tarball, unpackTarget, dMode, fMode, uid, gid, cb) {
+ log.verbose(tarball, "unpack")
if (typeof cb !== "function") cb = gid, gid = null
if (typeof cb !== "function") cb = uid, uid = null
if (typeof cb !== "function") cb = fMode, fMode = npm.modes.file
}
function unpack_ ( tarball, unpackTarget, dMode, fMode, uid, gid, cb ) {
- // If the desired target is /path/to/foo,
- // then unpack into /path/to/.foo.npm/{something}
- // rename that to /path/to/foo, and delete /path/to/.foo.npm
var parent = path.dirname(unpackTarget)
, base = path.basename(unpackTarget)
- , tmp = path.resolve(parent, "___" + base + ".npm")
- mkdir(tmp, dMode || npm.modes.exec, uid, gid, function (er) {
- log.verbose([uid, gid], "unpack_ uid, gid")
- log.verbose(unpackTarget, "unpackTarget")
- if (er) return log.er(cb, "Could not create "+tmp)(er)
- // cp the gzip of the tarball, pipe the stdout into tar's stdin
+ rm(unpackTarget, function (er) {
+ if (er) return cb(er)
+
// gzip {tarball} --decompress --stdout \
// | tar -mvxpf - --strip-components=1 -C {unpackTarget}
- gunzTarPerm( tarball, tmp
+ gunzTarPerm( tarball, unpackTarget
, dMode, fMode
, uid, gid
, function (er, folder) {
if (er) return cb(er)
- log.verbose(folder, "gunzed")
-
- rm(unpackTarget, function (er) {
- if (er) return cb(er)
- log.verbose(unpackTarget, "rm'ed")
-
- moveIntoPlace(folder, unpackTarget, function (er) {
- if (er) return cb(er)
- log.verbose([folder, unpackTarget], "renamed")
- // curse you, nfs! It will lie and tell you that the
- // mv is done, when in fact, it isn't. In theory,
- // reading the file should cause it to wait until it's done.
- readJson( path.resolve(unpackTarget, "package.json")
- , function (er, data) {
- // now we read the json, so we know it's there.
- rm(tmp, function (er2) { cb(er || er2, data) })
- })
- })
- })
+ readJson(path.resolve(folder, "package.json"), cb)
})
})
}
-// on Windows, A/V software can lock the directory, causing this
-// to fail with an EACCES. Try again on failure, for up to 1 second.
-// XXX Fix this by not unpacking into a temp directory, instead just
-// renaming things on the way out of the tarball.
-function moveIntoPlace (folder, unpackTarget, cb) {
- var start = Date.now()
- fs.rename(folder, unpackTarget, function CB (er) {
- if (er
- && process.platform === "win32"
- && er.code === "EACCES"
- && Date.now() - start < 1000) {
- return fs.rename(folder, unpackTarget, CB)
- }
- cb(er)
- })
-}
-
-function gunzTarPerm (tarball, tmp, dMode, fMode, uid, gid, cb) {
+function gunzTarPerm (tarball, target, dMode, fMode, uid, gid, cb_) {
if (!dMode) dMode = npm.modes.exec
if (!fMode) fMode = npm.modes.file
log.silly([dMode.toString(8), fMode.toString(8)], "gunzTarPerm modes")
- fs.createReadStream(tarball)
- .on("error", log.er(cb, "error reading "+tarball))
- .pipe(zlib.Unzip())
- .on("error", log.er(cb, "unzip error "+tarball))
- .pipe(tar.Extract({ type: "Directory", path: tmp }))
- .on("error", log.er(cb, "Failed unpacking "+tarball))
- .on("close", afterUntar)
-
- //
- // XXX Do all this in an Extract filter.
- //
- function afterUntar (er) {
- log.silly(er, "afterUntar")
- // if we're not doing ownership management,
- // then we're done now.
- if (er) return log.er(cb, "Failed unpacking "+tarball)(er)
-
- // HACK skip on windows
- if (npm.config.get("unsafe-perm") && process.platform !== "win32") {
- uid = process.getuid()
- gid = process.getgid()
- if (uid === 0) {
- if (process.env.SUDO_UID) uid = +process.env.SUDO_UID
- if (process.env.SUDO_GID) gid = +process.env.SUDO_GID
- }
- }
-
- if (process.platform === "win32") {
- return fs.readdir(tmp, function (er, files) {
- files = files.filter(function (f) {
- return f && f.indexOf("\0") === -1
- })
- cb(er, files && path.resolve(tmp, files[0]))
- })
- }
-
- find(tmp, function (f) {
- return f !== tmp
- }, function (er, files) {
- if (er) return cb(er)
- asyncMap(files, function (f, cb) {
- f = path.resolve(f)
- log.silly(f, "asyncMap in gTP")
- fs.lstat(f, function (er, stat) {
-
- if (er || stat.isSymbolicLink()) return cb(er)
- if (typeof uid === "number" && typeof gid === "number") {
- fs.chown(f, uid, gid, chown)
- } else chown()
-
- function chown (er) {
- if (er) return cb(er)
- var mode = stat.isDirectory() ? dMode : fMode
- , oldMode = stat.mode & 0777
- , newMode = (oldMode | mode) & (~npm.modes.umask)
- if (mode && newMode !== oldMode) {
- log.silly(newMode.toString(8), "chmod "+path.basename(f))
- fs.chmod(f, newMode, cb)
- } else cb()
- }
- })
- }, function (er) {
-
- if (er) return cb(er)
- if (typeof myUid === "number" && typeof myGid === "number") {
- fs.chown(tmp, myUid, myGid, chown)
- } else chown()
-
- function chown (er) {
- if (er) return cb(er)
- fs.readdir(tmp, function (er, folder) {
- folder = folder && folder.filter(function (f) {
- return f && !f.match(/^\._/)
- })
- cb(er, folder && path.resolve(tmp, folder[0]))
- })
- }
- })
- })
+ var cbCalled = false
+ function cb (er) {
+ if (cbCalled) return
+ cbCalled = true
+ cb_(er, target)
}
-}
-
-function makeList (dir, pkg, dfc, cb) {
- if (typeof cb !== "function") cb = dfc, dfc = true
- if (typeof cb !== "function") cb = pkg, pkg = null
- dir = path.resolve(dir)
-
- if (!pkg.path) pkg.path = dir
-
- var name = path.basename(dir)
-
- // since this is a top-level traversal, get the user and global
- // exclude files, as well as the "ignore" config setting.
- var confIgnore = npm.config.get("ignore").trim()
- .split(/[\n\r\s\t]+/)
- .filter(function (i) { return i.trim() })
- , userIgnore = npm.config.get("userignorefile")
- , globalIgnore = npm.config.get("globalignorefile")
- , userExclude
- , globalExclude
-
- confIgnore.dir = dir
- confIgnore.name = "confIgnore"
-
- var defIgnore = ["build/"]
- defIgnore.dir = dir
-
- // TODO: only look these up once, and cache outside this function
- excludes.parseIgnoreFile( userIgnore, null, dir
- , function (er, uex) {
- if (er) return cb(er)
- userExclude = uex
- next()
- })
- excludes.parseIgnoreFile( globalIgnore, null, dir
- , function (er, gex) {
- if (er) return cb(er)
- globalExclude = gex
- next()
- })
+ var fst = fs.createReadStream(tarball)
- function next () {
- if (!globalExclude || !userExclude) return
- var exList = [ defIgnore, confIgnore, globalExclude, userExclude ]
-
- makeList_(dir, pkg, exList, dfc, function (er, files, cleanup) {
- if (er) return cb(er)
- var dirLen = dir.replace(/(\/|\\)$/, "").length + 1
- log.silly([dir, dirLen], "dir, dirLen")
- files = files.map(function (file) {
- return path.join(name, file.substr(dirLen))
- })
- return cb(null, files, cleanup)
- })
+ // figure out who we're supposed to be, if we're not pretending
+ // to be a specific user.
+ if (npm.config.get("unsafe-perm") && process.platform !== "win32") {
+ uid = myUid
+ gid = myGid
}
-}
-
-// Patterns ending in slashes will only match targets
-// ending in slashes. To implement this, add a / to
-// the filename iff it lstats isDirectory()
-function readDir (dir, pkg, dfc, cb) {
- fs.readdir(dir, function (er, files) {
- if (er) return cb(er)
- files = files.filter(function (f) {
- return f && f.charAt(0) !== "/" && f.indexOf("\0") === -1
- })
- asyncMap(files, function (file, cb) {
- fs.lstat(path.resolve(dir, file), function (er, st) {
- if (er) return cb(null, [])
- // if it's a directory, then tack "/" onto the name
- // so that it can match dir-only patterns in the
- // include/exclude logic later.
- if (st.isDirectory()) return cb(null, file + "/")
-
- // if it's a symlink, then we need to do some more
- // complex stuff for GH-691
- if (st.isSymbolicLink()) return readSymlink(dir, file, pkg, dfc, cb)
-
- // otherwise, just let it on through.
- return cb(null, file)
- })
- }, cb)
- })
-}
-
-// just see where this link is pointing, and resolve relative paths.
-function shallowReal (link, cb) {
- link = path.resolve(link)
- fs.readlink(link, function (er, t) {
- if (er) return cb(er)
- return cb(null, path.resolve(path.dirname(link), t), t)
- })
-}
-
-function readSymlink (dir, file, pkg, dfc, cb) {
- var isNM = dfc
- && path.basename(dir) === "node_modules"
- && path.dirname(dir) === pkg.path
- // see if this thing is pointing outside of the package.
- // external symlinks are resolved for deps, ignored for other things.
- // internal symlinks are allowed through.
- var df = path.resolve(dir, file)
- shallowReal(df, function (er, r, target) {
- if (er) return cb(null, []) // wtf? exclude file.
- if (r.indexOf(dir) === 0) return cb(null, file) // internal
- if (!isNM) return cb(null, []) // external non-dep
- // now the fun stuff!
- fs.realpath(df, function (er, resolved) {
- if (er) return cb(null, []) // can't add it.
- readJson(path.resolve(resolved, "package.json"), function (er) {
- if (er) return cb(null, []) // not a package
- resolveLinkDep(dir, file, resolved, target, pkg, function (er, f, c) {
- cb(er, f, c)
- })
- })
- })
- })
-}
-
-// put the link back the way it was.
-function cleanupResolveLinkDep (cleanup, cb) {
- // cut it out of the list, so that cycles will be broken.
- if (!cleanup) return cb()
- asyncMap(cleanup, function (d, cb) {
- rm(d[1], function (er) {
- if (er) return cb(er)
- fs.symlink(d[0], d[1], cb)
- })
- }, cb)
-}
-
-function resolveLinkDep (dir, file, resolved, target, pkg, cb) {
- // we've already decided that this is a dep that will be bundled.
- // make sure the data reflects this.
- var bd = pkg.bundleDependencies || pkg.bundledDependencies || []
- delete pkg.bundledDependencies
- pkg.bundleDependencies = bd
- var f = path.resolve(dir, file)
- , cleanup = [[target, f, resolved]]
+ function extractEntry (entry) {
+ log.silly(entry.path, "extracting entry")
+ // never create things that are user-unreadable,
+ // or dirs that are user-un-listable. Only leads to headaches.
+ var originalMode = entry.mode = entry.mode || entry.props.mode
+ entry.mode = entry.mode | (entry.type === "Directory" ? dMode : fMode)
+ entry.mode = entry.mode & (~npm.modes.umask)
+ entry.props.mode = entry.mode
+ if (originalMode !== entry.mode) {
+ log.silly([entry.path, originalMode, entry.mode], "modified mode")
+ }
- if (bd.indexOf(file) === -1) {
- // then we don't do this one.
- // just move the symlink out of the way.
- return rm(f, function (er) {
- cb(er, file, cleanup)
- })
+ // if there's a specific owner uid/gid that we want, then set that
+ if (process.platform !== "win32" &&
+ typeof uid === "number" &&
+ typeof gid === "number") {
+ entry.props.uid = entry.uid = uid
+ entry.props.gid = entry.gid = gid
+ }
}
- rm(f, function (er) {
- if (er) return cb(er)
- cache.add(resolved, function (er, data) {
- if (er) return cb(er)
- cache.unpack(data.name, data.version, f, function (er, data) {
- if (er) return cb(er)
- // now clear out the cache entry, since it's weird, probably.
- // pass the cleanup object along so that the thing getting the
- // list of files knows what to clean up afterwards.
- cache.clean([data._id], function (er) { cb(er, file, cleanup) })
- })
- })
- })
-}
-
-// exList is a list of ignore lists.
-// Each exList item is an array of patterns of files to ignore
-//
-function makeList_ (dir, pkg, exList, dfc, cb) {
- var files = null
- , cleanup = null
+ var extractOpts = { type: "Directory", path: target, strip: 1 }
- readDir(dir, pkg, dfc, function (er, f, c) {
- if (er) return cb(er)
- cleanup = c
- files = f.map(function (f) {
- // no nulls in paths!
- return f.split(/\0/)[0]
- }).filter(function (f) {
- // always remove all source control folders and
- // waf/vim/OSX garbage. this is a firm requirement.
- return !( f === ".git/"
- || f === ".lock-wscript"
- || f === "CVS/"
- || f === ".svn/"
- || f === ".hg/"
- || f.match(/^\..*\.swp/)
- || f === ".DS_Store"
- || f.match(/^\._/)
- || f === "npm-debug.log"
- || f === ""
- || f.charAt(0) === "/"
- )
- })
-
- // if (files.length > 0) files.push(".")
-
- if (files.indexOf("package.json") !== -1 && dir !== pkg.path) {
- // a package.json file starts the whole exclude/include
- // logic all over. Otherwise, a parent could break its
- // deps with its files list or .npmignore file.
- readJson(path.resolve(dir, "package.json"), function (er, data) {
- if (!er && typeof data === "object") {
- data.path = dir
- return makeList(dir, data, dfc, function (er, files) {
- // these need to be mounted onto the directory now.
- cb(er, files && files.map(function (f) {
- return path.resolve(path.dirname(dir), f)
- }))
- })
- }
- next()
- })
- //next()
- } else next()
+ if (process.platform !== "win32" &&
+ typeof uid === "number" &&
+ typeof gid === "number") {
+ extractOpts.uid = uid
+ extractOpts.gid = gid
+ }
- // add a local ignore file, if found.
- if (files.indexOf(".npmignore") === -1
- && files.indexOf(".gitignore") === -1) next()
- else {
- excludes.addIgnoreFile( path.resolve(dir, ".npmignore")
- , ".gitignore"
- , exList
- , dir
- , function (er, list) {
- if (!er) exList = list
- next(er)
- })
+ extractOpts.filter = function () {
+ // symbolic links are not allowed in packages.
+ if (this.type.match(/^.*Link$/)) {
+ log.warn( this.path.substr(target.length + 1)
+ + ' -> ' + this.linkpath
+ , "excluding symbolic link")
+ return false
}
- })
+ return true
+ }
- var n = 2
- , errState = null
- function next (er) {
- if (errState) return
- if (er) return cb(errState = er, [], cleanup)
- if (-- n > 0) return
- if (!pkg) return cb(new Error("No package.json file in "+dir))
- if (pkg.path === dir && pkg.files) {
- pkg.files = pkg.files.filter(function (f) {
- f = f.trim()
- return f && f.charAt(0) !== "#"
- })
- if (!pkg.files.length) pkg.files = null
- }
- if (pkg.path === dir && pkg.files) {
- // stuff on the files list MUST be there.
- // ignore everything, then include the stuff on the files list.
- var pkgFiles = ["*"].concat(pkg.files.map(function (f) {
- return "!" + f
- }))
- pkgFiles.dir = dir
- pkgFiles.packageFiles = true
- exList.push(pkgFiles)
- }
-
- if (path.basename(dir) === "node_modules"
- && pkg.path === path.dirname(dir)
- && dfc) { // do fancy crap
- files = filterNodeModules(files, pkg)
+ fst.on("error", log.er(cb, "error reading "+tarball))
+ fst.on("data", function OD (c) {
+ // detect what it is.
+ // Then, depending on that, we'll figure out whether it's
+ // a single-file module, gzipped tarball, or naked tarball.
+ // gzipped files all start with 1f8b08
+ if (c[0] === 0x1F &&
+ c[1] === 0x8B &&
+ c[2] === 0x08) {
+ fst
+ .pipe(zlib.Unzip())
+ .on("error", log.er(cb, "unzip error "+tarball))
+ .pipe(tar.Extract(extractOpts))
+ .on("entry", extractEntry)
+ .on("error", log.er(cb, "untar error "+tarball))
+ .on("close", cb)
+ } else if (c.toString().match(/^package\//)) {
+ // naked tar
+ fst
+ .pipe(tar.Extract(extractOpts))
+ .on("entry", extractEntry)
+ .on("error", log.er(cb, "untar error "+tarball))
+ .on("close", cb)
} else {
- // If a directory is excluded, we still need to be
- // able to *include* a file within it, and have that override
- // the prior exclusion.
- //
- // This whole makeList thing probably needs to be rewritten
- files = files.filter(function (f) {
- return excludes.filter(dir, exList)(f) || f.slice(-1) === "/"
- })
- }
-
-
- asyncMap(files, function (file, cb) {
- // if this is a dir, then dive into it.
- // otherwise, don't.
- file = path.resolve(dir, file)
-
- // in 0.6.0, fs.readdir can produce some really odd results.
- // XXX: remove this and make the engines hash exclude 0.6.0
- if (file.indexOf(dir) !== 0) {
- return cb(null, [])
+ // naked js file
+ var jsOpts = { path: path.resolve(target, "index.js") }
+
+ if (process.platform !== "win32" &&
+ typeof uid === "number" &&
+ typeof gid === "number") {
+ jsOpts.uid = uid
+ jsOpts.gid = gid
}
- fs.lstat(file, function (er, st) {
- if (er) return cb(er)
- if (st.isDirectory()) {
- return makeList_(file, pkg, exList, dfc, cb)
- }
- return cb(null, file)
- })
- }, function (er, files, c) {
- if (c) cleanup = (cleanup || []).concat(c)
- if (files.length > 0) files.push(dir)
- return cb(er, files, cleanup)
- })
- }
-}
-
-// only include node_modules folder that are:
-// 1. not on the dependencies list or
-// 2. on the "bundleDependencies" list.
-function filterNodeModules (files, pkg) {
- var bd = pkg.bundleDependencies || pkg.bundledDependencies || []
- , deps = Object.keys(pkg.dependencies || {})
- .filter(function (key) { return !pkg.dependencies[key].extraneous })
- .concat(Object.keys(pkg.devDependencies || {}))
-
- delete pkg.bundledDependencies
- pkg.bundleDependencies = bd
+ fst
+ .pipe(fstream.Writer(jsOpts))
+ .on("error", log.er(cb, "copy error "+tarball))
+ .on("close", function () {
+ var j = path.resolve(target, "package.json")
+ readJson(j, function (er, d) {
+ if (er) {
+ log.error(tarball, "Not a package")
+ return cb(er)
+ }
+ fs.writeFile(j, JSON.stringify(d) + "\n", cb)
+ })
+ })
+ }
- return files.filter(function (f) {
- f = f.replace(/\/$/, "")
- return f.charAt(0) !== "."
- && f.charAt(0) !== "_"
- && bd.indexOf(f) !== -1
+ // now un-hook, and re-emit the chunk
+ fst.removeListener("data", OD)
+ fst.emit("data", c)
})
}
+++ /dev/null
-module.exports = uidNumber
-
-// This module calls into bin/npm-get-uid-gid.js, which sets the
-// uid and gid to the supplied argument, in order to find out their
-// numeric value. This can't be done in the main node process,
-// because otherwise npm would be running as that user.
-
-var exec = require("./exec.js")
- , path = require("path")
- , log = require("./log.js")
- , constants = require("constants")
- , npm = require("../npm.js")
- , uidSupport = process.getuid && process.setuid
- , uidCache = {}
- , gidCache = {}
-
-function uidNumber (uid, gid, cb) {
- if (!uidSupport || npm.config.get("unsafe-perm")) return cb()
- if (typeof cb !== "function") cb = gid, gid = null
- if (typeof cb !== "function") cb = uid, uid = null
- if (gid == null) gid = process.getgid()
- if (uid == null) uid = process.getuid()
- if (!isNaN(gid)) gid = +gid
- if (!isNaN(uid)) uid = +uid
-
- if (uidCache[uid]) uid = uidCache[uid]
- if (gidCache[gid]) gid = gidCache[gid]
-
- if (typeof gid === "number" && typeof uid === "number") {
- return cb(null, uid, gid)
- }
-
- var getter = path.join(__dirname, "..", "..", "bin", "npm-get-uid-gid.js")
- return exec( process.execPath, [getter, uid, gid], process.env, false
- , null, process.getuid(), process.getgid()
- , function (er, code, out, err) {
- if (er) return log.er(cb, "Could not get uid/gid "+err)(er)
- log.silly(out, "output from getuid/gid")
- out = JSON.parse(out+"")
- if (out.error) {
- if (!npm.config.get("unsafe-perm")) {
- var er = new Error(out.error)
- er.errno = out.errno
- return cb(er)
- } else {
- return cb(null, +process.getuid(), +process.getgid())
- }
- }
- if (isNaN(out.uid) || isNaN(out.gid)) return cb(new Error(
- "Could not get uid/gid: "+JSON.stringify(out)))
- uidCache[uid] = out.uid
- uidCache[gid] = out.gid
- cb(null, out.uid, out.gid)
- })
-}
}
function write (data, cb) {
fs.writeFile( path.join(process.cwd(), "package.json")
- , new Buffer(JSON.stringify(data, null, 2))
+ , new Buffer(JSON.stringify(data, null, 2) + "\n")
, cb )
}
data.versions = Object.keys(data.versions).sort(semver.compare)
if (!args.length) args = [""]
+ // remove readme unless we asked for it
if (-1 === args.indexOf("readme")) {
delete data.readme
}
delete versions[v]
}
if (semver.satisfies(v, version)) args.forEach(function (args) {
+ // remove readme unless we asked for it
+ if (-1 === args.indexOf("readme")) {
+ delete versions[v].readme
+ }
results.push(showFields(data, versions[v], args))
})
})
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM" "1" "January 2012" "" ""
+.TH "NPM" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm\fR \-\- node package manager
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-ADDUSER" "1" "January 2012" "" ""
+.TH "NPM\-ADDUSER" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-adduser\fR \-\- Add a registry user account
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-BIN" "1" "January 2012" "" ""
+.TH "NPM\-BIN" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-bin\fR \-\- Display npm bin folder
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-BUGS" "1" "January 2012" "" ""
+.TH "NPM\-BUGS" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-bugs\fR \-\- Bugs for a package in a web browser maybe
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-BUILD" "1" "January 2012" "" ""
+.TH "NPM\-BUILD" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-build\fR \-\- Build a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-BUNDLE" "1" "January 2012" "" ""
+.TH "NPM\-BUNDLE" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-bundle\fR \-\- REMOVED
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-CACHE" "1" "January 2012" "" ""
+.TH "NPM\-CACHE" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-cache\fR \-\- Manipulates packages cache
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-CHANGELOG" "1" "January 2012" "" ""
+.TH "NPM\-CHANGELOG" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-changelog\fR \-\- Changes
.
.SH "HISTORY"
.
+.SS "1\.1\.3, 1\.1\.4"
+.
+.IP "\(bu" 4
+Update request to support HTTPS\-over\-HTTP proxy tunneling
+.
+.IP "\(bu" 4
+Throw on undefined envs in config settings
+.
+.IP "\(bu" 4
+Update which to 1\.0\.5
+.
+.IP "\(bu" 4
+Fix windows UNC busyloop in findPrefix
+.
+.IP "\(bu" 4
+Bundle nested bundleDependencies properly
+.
+.IP "\(bu" 4
+Alias adduser to add\-user
+.
+.IP "\(bu" 4
+Doc updates (Christian Howe, Henrik Hodne, Andrew Lunny)
+.
+.IP "\(bu" 4
+ignore logfd/outfd streams in makeEnv() (Rod Vagg)
+.
+.IP "\(bu" 4
+shrinkwrap: Behave properly with url\-installed deps
+.
+.IP "\(bu" 4
+install: Support \-\-save with url install targets
+.
+.IP "\(bu" 4
+Support installing naked tars or single\-file modules from urls etc\.
+.
+.IP "\(bu" 4
+init: Don\'t add engines section
+.
+.IP "\(bu" 4
+Don\'t run make clean on rebuild
+.
+.IP "\(bu" 4
+Added missing unicode replacement (atomizer)
+.
+.IP "" 0
+.
+.SS "1\.1\.2"
+Dave Pacheco (2):
+ add "npm shrinkwrap"
+.
+.P
+Martin Cooper (1):
+ Fix #1753 Make a copy of the cached objects we\'ll modify\.
+.
+.P
+Tim Oxley (1):
+ correctly remove readme from default npm view command\.
+.
+.P
+Tyler Green (1):
+ fix #2187 set terminal columns to Infinity if 0
+.
+.P
+isaacs (19):
+ update minimatch
+ update request
+ Experimental: single\-file modules
+ Fix #2172 Don\'t remove global mans uninstalling local pkgs
+ Add \-\-versions flag to show the version of node as well
+ Support \-\-json flag for ls output
+ update request to 2\.9\.151
+.
+.SS "1\.1"
+.
+.IP "\(bu" 4
+Replace system tar dependency with a JS tar
+.
+.IP "\(bu" 4
+Continue to refine
+.
+.IP "" 0
+.
.SS "1\.0"
.
.IP "\(bu" 4
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-CODING\-STYLE" "1" "January 2012" "" ""
+.TH "NPM\-CODING\-STYLE" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-coding-style\fR \-\- npm\'s "funny" coding style
reason for doing that\.)
.
.IP "\(bu" 4
-case "foo": doSomething(); break
+\fBcase "foo": doSomething(); break\fR
.
.IP "\(bu" 4
-In front of a leading ( or [ at the start of the line\.
+In front of a leading \fB(\fR or \fB[\fR at the start of the line\.
This prevents the expression from being interpreted
as a function call or property access, respectively\.
.
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-COMPLETION" "1" "January 2012" "" ""
+.TH "NPM\-COMPLETION" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-completion\fR \-\- Tab Completion for npm
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-CONFIG" "1" "January 2012" "" ""
+.TH "NPM\-CONFIG" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-config\fR \-\- Manage the npm configuration file
\fB\-S\fR: \fB\-\-save\fR
.
.IP "\(bu" 4
+\fB\-D\fR: \fB\-\-save\-dev\fR
+.
+.IP "\(bu" 4
+\fB\-O\fR: \fB\-\-save\-optional\fR
+.
+.IP "\(bu" 4
\fB\-y\fR: \fB\-\-yes\fR
.
.IP "\(bu" 4
.P
The location of npm\'s cache directory\. See \fBnpm help cache\fR
.
+.SS "cache\-max"
+.
+.IP "\(bu" 4
+Default: Infinity
+.
+.IP "\(bu" 4
+Type: Number
+.
+.IP "" 0
+.
+.P
+The maximum time (in seconds) to keep items in the registry cache before
+re\-checking against the registry\.
+.
+.P
+Note that no purging is done unless the \fBnpm cache clean\fR command is
+explicitly used, and that only GET requests use the cache\.
+.
+.SS "cache\-min"
+.
+.IP "\(bu" 4
+Default: 0
+.
+.IP "\(bu" 4
+Type: Number
+.
+.IP "" 0
+.
+.P
+The minimum time (in seconds) to keep items in the registry cache before
+re\-checking against the registry\.
+.
+.P
+Note that no purging is done unless the \fBnpm cache clean\fR command is
+explicitly used, and that only GET requests use the cache\.
+.
.SS "color"
.
.IP "\(bu" 4
.P
A proxy to use for outgoing https requests\.
.
+.SS "user\-agent"
+.
+.IP "\(bu" 4
+Default: npm/{npm\.version} node/{process\.version}
+.
+.IP "\(bu" 4
+Type: String
+.
+.IP "" 0
+.
+.P
+Sets a User\-Agent to the request header
+.
.SS "ignore"
.
.IP "\(bu" 4
.SS "init\.author\.name"
.
.IP "\(bu" 4
-Default: "0\.0\.0"
+Default: ""
.
.IP "\(bu" 4
Type: String
.P
The value \fBnpm init\fR should use by default for the package author\'s homepage\.
.
+.SS "json"
+.
+.IP "\(bu" 4
+Default: false
+.
+.IP "\(bu" 4
+Type: Boolean
+.
+.IP "" 0
+.
+.P
+Whether or not to output JSON data, rather than the normal output\.
+.
+.P
+This feature is currently experimental, and the output data structures
+for many commands is either not implemented in JSON yet, or subject to
+change\. Only the output from \fBnpm ls \-\-json\fR is currently valid\.
+.
.SS "link"
.
.IP "\(bu" 4
.P
Only works if there is already a package\.json file present\.
.
+.SS "save\-dev"
+.
+.IP "\(bu" 4
+Default: false
+.
+.IP "\(bu" 4
+Type: Boolean
+.
+.IP "" 0
+.
+.P
+Save installed packages to a package\.json file as devDependencies\.
+.
+.P
+Only works if there is already a package\.json file present\.
+.
+.SS "save\-optional"
+.
+.IP "\(bu" 4
+Default: false
+.
+.IP "\(bu" 4
+Type: Boolean
+.
+.IP "" 0
+.
+.P
+Save installed packages to a package\.json file as optionalDependencies\.
+.
+.P
+Only works if there is already a package\.json file present\.
+.
.SS "searchopts"
.
.IP "\(bu" 4
.P
Only relevant when specified explicitly on the command line\.
.
+.SS "versions"
+.
+.IP "\(bu" 4
+Default: false
+.
+.IP "\(bu" 4
+Type: boolean
+.
+.IP "" 0
+.
+.P
+If true, output the npm version as well as node\'s \fBprocess\.versions\fR
+hash, and exit successfully\.
+.
+.P
+Only relevant when specified explicitly on the command line\.
+.
.SS "viewer"
.
.IP "\(bu" 4
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-DEPRECATE" "1" "January 2012" "" ""
+.TH "NPM\-DEPRECATE" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-deprecate\fR \-\- Deprecate a version of a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-DEVELOPERS" "1" "January 2012" "" ""
+.TH "NPM\-DEVELOPERS" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-developers\fR \-\- Developer Guide
.IP "\(bu" 4
f) a \fB<name>\fR that has a "latest" tag satisfying (e)
.
+.IP "\(bu" 4
+g) a \fBgit\fR url that, when cloned, results in (a)\.
+.
.IP "" 0
.
.P
perhaps if you also want to be able to easily install it elsewhere
after packing it up into a tarball (b)\.
.
+.P
+Git urls can be of the form:
+.
+.IP "" 4
+.
+.nf
+git://github\.com/user/project\.git#commit\-ish
+git+ssh://user@hostname:project\.git#commit\-ish
+git+http://user@hostname/project/blah\.git#commit\-ish
+git+https://user@hostname/project/blah\.git#commit\-ish
+.
+.fi
+.
+.IP "" 0
+.
+.P
+The \fBcommit\-ish\fR can be any tag, sha, or branch which can be supplied as
+an argument to \fBgit checkout\fR\|\. The default is \fBmaster\fR\|\.
+.
.SH "The package\.json File"
You need to have a \fBpackage\.json\fR file in the root of your project to do
much of anything with npm\. That is basically the whole interface\.
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-DISPUTES" "1" "January 2012" "" ""
+.TH "NPM\-DISPUTES" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-disputes\fR \-\- Handling Module Name Disputes
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-DOCS" "1" "January 2012" "" ""
+.TH "NPM\-DOCS" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-docs\fR \-\- Docs for a package in a web browser maybe
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-EDIT" "1" "January 2012" "" ""
+.TH "NPM\-EDIT" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-edit\fR \-\- Edit an installed package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-EXPLORE" "1" "January 2012" "" ""
+.TH "NPM\-EXPLORE" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-explore\fR \-\- Browse an installed package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-FAQ" "1" "January 2012" "" ""
+.TH "NPM\-FAQ" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-faq\fR \-\- Frequently Asked Questions
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-FOLDERS" "1" "January 2012" "" ""
+.TH "NPM\-FOLDERS" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-folders\fR \-\- Folder Structures Used by npm
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-HELP\-SEARCH" "1" "January 2012" "" ""
+.TH "NPM\-HELP\-SEARCH" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-help-search\fR \-\- Search npm help documentation
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-HELP" "1" "January 2012" "" ""
+.TH "NPM\-HELP" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-help\fR \-\- Get help on npm
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-INDEX" "1" "January 2012" "" ""
+.TH "NPM\-INDEX" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-index\fR \-\- Index of all npm documentation
.SH "npm help semver"
The semantic versioner for npm
.
+.SH "npm help shrinkwrap"
+ Lock down dependency versions
+.
.SH "npm help star"
Mark your favorite packages
.
.SH "npm apihelp search"
Search for packages
.
+.SH "npm apihelp shrinkwrap"
+ programmatically generate package shrinkwrap file
+.
.SH "npm apihelp start"
Start a package
.
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-INIT" "1" "January 2012" "" ""
+.TH "NPM\-INIT" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-init\fR \-\- Interactively create a package\.json file
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-INSTALL" "1" "January 2012" "" ""
+.TH "NPM\-INSTALL" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-install\fR \-\- Install a package
npm install <tarball file>
npm install <tarball url>
npm install <folder>
-npm install <name>
+npm install <name> [\-\-save|\-\-save\-dev|\-\-save\-optional]
npm install <name>@<tag>
npm install <name>@<version>
npm install <name>@<version range>
+npm install <name>@<version range>
.
.fi
.
.SH "DESCRIPTION"
-This command installs a package, and any packages that it depends on\.
+This command installs a package, and any packages that it depends on\. If the
+package has a shrinkwrap file, the installation of dependencies will be driven
+by that\. See npm help shrinkwrap\.
.
.P
A \fBpackage\fR is:
.
.IP "\(bu" 4
\fBnpm install\fR (in package directory, no arguments):
+.
+.IP
Install the dependencies in the local node_modules folder\.
.
.IP
.
.IP "\(bu" 4
\fBnpm install <folder>\fR:
+.
+.IP
Install a package that is sitting in a folder on the filesystem\.
.
.IP "\(bu" 4
\fBnpm install <tarball file>\fR:
+.
+.IP
Install a package that is sitting on the filesystem\. Note: if you just want
to link a dev directory into your npm root, you can do this more easily by
using \fBnpm link\fR\|\.
.IP "" 4
.
.nf
-npm install \./package\.tgz
+ npm install \./package\.tgz
.
.fi
.
.
.IP "\(bu" 4
\fBnpm install <tarball url>\fR:
+.
+.IP
Fetch the tarball url, and then install it\. In order to distinguish between
this and other options, the argument must start with "http://" or "https://"
.
.IP "" 4
.
.nf
-npm install https://github\.com/indexzero/forever/tarball/v0\.5\.6
+ npm install https://github\.com/indexzero/forever/tarball/v0\.5\.6
.
.fi
.
.
.IP "\(bu" 4
-\fBnpm install <name>\fR:
-Do a \fB<name>@<tag>\fR install, where \fB<tag>\fR is the "tag" config\. (See \fBnpm help config\fR)
+\fBnpm install <name> [\-\-save|\-\-save\-dev|\-\-save\-optional]\fR:
+.
+.IP
+Do a \fB<name>@<tag>\fR install, where \fB<tag>\fR is the "tag" config\. (See \fBnpm help config\fR\|\.)
+.
+.IP
+In most cases, this will install the latest version
+of the module published on npm\.
.
.IP
Example:
.
-.IP "" 4
+.IP
+ npm install sax
.
-.nf
-npm install sax
+.IP
+\fBnpm install\fR takes 3 exclusive, optional flags which save or update
+the package version in your main package\.json:
.
-.fi
+.IP "\(bu" 4
+\fB\-\-save\fR: Package will appear in your \fBdependencies\fR\|\.
.
-.IP "" 0
+.IP "\(bu" 4
+\fB\-\-save\-dev\fR: Package will appear in your \fBdevDependencies\fR\|\.
+.
+.IP "\(bu" 4
+\fB\-\-save\-optional\fR: Package will appear in your \fBoptionalDependencies\fR\|\.
+.
+.IP
+Examples:
+.
+.IP
+ npm install sax \-\-save
+ npm install node\-tap \-\-save\-dev
+ npm install dtrace\-provider \-\-save\-optional
.
.IP
\fBNote\fR: If there is a file or folder named \fB<name>\fR in the current
working directory, then it will try to install that, and only try to
fetch the package by name if it is not valid\.
.
+.IP "" 0
+
+.
.IP "\(bu" 4
\fBnpm install <name>@<tag>\fR:
+.
+.IP
Install the version of the package that is referenced by the specified tag\.
If the tag does not exist in the registry data for that package, then this
will fail\.
.IP "" 4
.
.nf
-npm install sax@latest
+ npm install sax@latest
.
.fi
.
.
.IP "\(bu" 4
\fBnpm install <name>@<version>\fR:
+.
+.IP
Install the specified version of the package\. This will fail if the version
has not been published to the registry\.
.
.IP "" 4
.
.nf
-npm install sax@0\.1\.1
+ npm install sax@0\.1\.1
.
.fi
.
.
.IP "\(bu" 4
\fBnpm install <name>@<version range>\fR:
+.
+.IP
Install a version of the package matching the specified version range\. This
will follow the same rules for resolving dependencies described in \fBnpm help json\fR\|\.
.
.IP
Example:
.
-.IP "" 4
-.
-.nf
-npm install sax@">=0\.1\.0 <0\.2\.0"
-.
-.fi
-.
-.IP "" 0
-
+.IP
+ npm install sax@">=0\.1\.0 <0\.2\.0"
.
.IP "\(bu" 4
\fBnpm install <git remote url>\fR:
Install a package by cloning a git remote url\. The format of the git
url is:
.
-.IP "" 4
-.
-.nf
-<protocol>://[<user>@]<hostname><separator><path>[#<commit\-ish>]
-.
-.fi
-.
-.IP "" 0
+.IP
+ <protocol>://[<user>@]<hostname><separator><path>[#<commit\-ish>]
.
.IP
\fB<protocol>\fR is one of \fBgit\fR, \fBgit+ssh\fR, \fBgit+http\fR, or \fBgit+https\fR\|\. If no \fB<commit\-ish>\fR is specified, then \fBmaster\fR is
.IP "" 4
.
.nf
-git+ssh://git@github\.com:isaacs/npm\.git#v1\.0\.27
-git+https://isaacs@github\.com/isaacs/npm\.git
-git://github\.com/isaacs/npm\.git#v1\.0\.27
+ git+ssh://git@github\.com:isaacs/npm\.git#v1\.0\.27
+ git+https://isaacs@github\.com/isaacs/npm\.git
+ git://github\.com/isaacs/npm\.git#v1\.0\.27
.
.fi
.
.IP "\(bu" 4
npm help rm
.
+.IP "\(bu" 4
+npm help shrinkwrap
+.
.IP "" 0
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-JSON" "1" "January 2012" "" ""
+.TH "NPM\-JSON" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-json\fR \-\- Specifics of npm\'s package\.json handling
.IP "\(bu" 4
\fBrange1 || range2\fR Passes if either range1 or range2 are satisfied\.
.
+.IP "\(bu" 4
+\fBgit\.\.\.\fR See \'Git URLs as Dependencies\' below
+.
.IP "" 0
.
.P
This tarball will be downloaded and installed locally to your package at
install time\.
.
+.SS "Git URLs as Dependencies"
+Git urls can be of the form:
+.
+.IP "" 4
+.
+.nf
+git://github\.com/user/project\.git#commit\-ish
+git+ssh://user@hostname:project\.git#commit\-ish
+git+http://user@hostname/project/blah\.git#commit\-ish
+git+https://user@hostname/project/blah\.git#commit\-ish
+.
+.fi
+.
+.IP "" 0
+.
+.P
+The \fBcommit\-ish\fR can be any tag, sha, or branch which can be supplied as
+an argument to \fBgit checkout\fR\|\. The default is \fBmaster\fR\|\.
+.
.SH "devDependencies"
If someone is planning on downloading and using your module in their
program, then they probably don\'t want or need to download and build
.
.IP "" 0
.
+.SH "os"
+You can specify which operating systems your
+module will run on:
+.
+.IP "" 4
+.
+.nf
+"os" : [ "darwin", "linux" ]
+.
+.fi
+.
+.IP "" 0
+.
+.P
+You can also blacklist instead of whitelist operating systems,
+just prepend the blacklisted os with a \'!\':
+.
+.IP "" 4
+.
+.nf
+"os" : [ "!win32" ]
+.
+.fi
+.
+.IP "" 0
+.
+.P
+The host operating system is determined by \fBprocess\.platform\fR
+.
+.P
+It is allowed to both blacklist, and whitelist, although there isn\'t any
+good reason to do this\.
+.
+.SH "cpu"
+If your code only runs on certain cpu architectures,
+you can specify which ones\.
+.
+.IP "" 4
+.
+.nf
+"cpu" : [ "x64", "ia32" ]
+.
+.fi
+.
+.IP "" 0
+.
+.P
+Like the \fBos\fR option, you can also blacklist architectures:
+.
+.IP "" 4
+.
+.nf
+"cpu" : [ "!arm", "!mips" ]
+.
+.fi
+.
+.IP "" 0
+.
+.P
+The host architecture is determined by \fBprocess\.arch\fR
+.
.SH "preferGlobal"
If your package is primarily a command\-line application that should be
installed globally, then set this value to \fBtrue\fR to provide a warning
.P
This is a way to prevent accidental publication of private repositories\.
If you would like to ensure that a given package is only ever published
-to a speciic registry (for example, an internal registry),
+to a specific registry (for example, an internal registry),
then use the \fBpublishConfig\fR hash described below
to override the \fBregistry\fR config param at publish\-time\.
.
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-LINK" "1" "January 2012" "" ""
+.TH "NPM\-LINK" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-link\fR \-\- Symlink a package folder
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-LS" "1" "January 2012" "" ""
+.TH "NPM\-LS" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-ls\fR \-\- List installed packages
.
.SH "CONFIGURATION"
.
+.SS "json"
+.
+.IP "\(bu" 4
+Default: false
+.
+.IP "\(bu" 4
+Type: Boolean
+.
+.IP "" 0
+.
+.P
+Show information in JSON format\.
+.
.SS "long"
.
.IP "\(bu" 4
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM" "1" "January 2012" "" ""
+.TH "NPM" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm\fR \-\- node package manager
.fi
.
.SH "VERSION"
-1.1.0-2
+1.1.21
.
.SH "DESCRIPTION"
npm is the package manager for the Node JavaScript platform\. It puts
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-OUTDATED" "1" "January 2012" "" ""
+.TH "NPM\-OUTDATED" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-outdated\fR \-\- Check for outdated packages
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-OWNER" "1" "January 2012" "" ""
+.TH "NPM\-OWNER" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-owner\fR \-\- Manage package owners
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-PACK" "1" "January 2012" "" ""
+.TH "NPM\-PACK" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-pack\fR \-\- Create a tarball from a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-PREFIX" "1" "January 2012" "" ""
+.TH "NPM\-PREFIX" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-prefix\fR \-\- Display prefix
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-PRUNE" "1" "January 2012" "" ""
+.TH "NPM\-PRUNE" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-prune\fR \-\- Remove extraneous packages
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-PUBLISH" "1" "January 2012" "" ""
+.TH "NPM\-PUBLISH" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-publish\fR \-\- Publish a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-REBUILD" "1" "January 2012" "" ""
+.TH "NPM\-REBUILD" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-rebuild\fR \-\- Rebuild a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-REGISTRY" "1" "January 2012" "" ""
+.TH "NPM\-REGISTRY" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-registry\fR \-\- The JavaScript Package Registry
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-REMOVAL" "1" "January 2012" "" ""
+.TH "NPM\-REMOVAL" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-removal\fR \-\- Cleaning the Slate
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-RESTART" "1" "January 2012" "" ""
+.TH "NPM\-RESTART" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-restart\fR \-\- Start a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-ROOT" "1" "January 2012" "" ""
+.TH "NPM\-ROOT" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-root\fR \-\- Display npm root
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-RUN\-SCRIPT" "1" "January 2012" "" ""
+.TH "NPM\-RUN\-SCRIPT" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-run-script\fR \-\- Run arbitrary package scripts
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-SCRIPTS" "1" "January 2012" "" ""
+.TH "NPM\-SCRIPTS" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-scripts\fR \-\- How npm handles the "scripts" field
made available regarding the setup of npm and the current state of the
process\.
.
+.SS "path"
+If you depend on modules that define executable scripts, like test suites,
+then those executables will be added to the \fBPATH\fR for executing the scripts\.
+So, if your package\.json has this:
+.
+.IP "" 4
+.
+.nf
+{ "name" : "foo"
+, "dependencies" : { "bar" : "0\.1\.x" }
+, "scripts": { "start" : "bar \./test" } }
+.
+.fi
+.
+.IP "" 0
+.
+.P
+then you could run \fBnpm start\fR to execute the \fBbar\fR script, which is exported
+into the \fBnode_modules/\.bin\fR directory on \fBnpm install\fR\|\.
+.
.SS "package\.json vars"
The package\.json fields are tacked onto the \fBnpm_package_\fR prefix\. So, for
instance, if you had \fB{"name":"foo", "version":"1\.2\.5"}\fR in your package\.json
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-SEARCH" "1" "January 2012" "" ""
+.TH "NPM\-SEARCH" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-search\fR \-\- Search for packages
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-SEMVER" "1" "January 2012" "" ""
+.TH "NPM\-SEMVER" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-semver\fR \-\- The semantic versioner for npm
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-SHRINKWRAP" "1" "April 2012" "" ""
+.TH "NPM\-SHRINKWRAP" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-shrinkwrap\fR \-\- Lock down dependency versions
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-STAR" "1" "January 2012" "" ""
+.TH "NPM\-STAR" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-star\fR \-\- Mark your favorite packages
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-START" "1" "January 2012" "" ""
+.TH "NPM\-START" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-start\fR \-\- Start a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-STOP" "1" "January 2012" "" ""
+.TH "NPM\-STOP" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-stop\fR \-\- Stop a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-SUBMODULE" "1" "January 2012" "" ""
+.TH "NPM\-SUBMODULE" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-submodule\fR \-\- Add a package as a git submodule
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-TAG" "1" "January 2012" "" ""
+.TH "NPM\-TAG" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-tag\fR \-\- Tag a published version
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-TEST" "1" "January 2012" "" ""
+.TH "NPM\-TEST" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-test\fR \-\- Test a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-RM" "1" "January 2012" "" ""
+.TH "NPM\-RM" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-rm\fR \-\- Remove a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-UNPUBLISH" "1" "January 2012" "" ""
+.TH "NPM\-UNPUBLISH" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-unpublish\fR \-\- Remove a package from the registry
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-UPDATE" "1" "January 2012" "" ""
+.TH "NPM\-UPDATE" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-update\fR \-\- Update a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-VERSION" "1" "January 2012" "" ""
+.TH "NPM\-VERSION" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-version\fR \-\- Bump a package version
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-VIEW" "1" "January 2012" "" ""
+.TH "NPM\-VIEW" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-view\fR \-\- View registry info
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-WHOAMI" "1" "January 2012" "" ""
+.TH "NPM\-WHOAMI" "1" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-whoami\fR \-\- Display npm username
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-BIN" "3" "January 2012" "" ""
+.TH "NPM\-BIN" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-bin\fR \-\- Display npm bin folder
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-BUGS" "3" "January 2012" "" ""
+.TH "NPM\-BUGS" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-bugs\fR \-\- Bugs for a package in a web browser maybe
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-COMMANDS" "3" "January 2012" "" ""
+.TH "NPM\-COMMANDS" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-commands\fR \-\- npm commands
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-CONFIG" "3" "January 2012" "" ""
+.TH "NPM\-CONFIG" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-config\fR \-\- Manage the npm configuration files
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-DEPRECATE" "3" "January 2012" "" ""
+.TH "NPM\-DEPRECATE" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-deprecate\fR \-\- Deprecate a version of a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-DOCS" "3" "January 2012" "" ""
+.TH "NPM\-DOCS" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-docs\fR \-\- Docs for a package in a web browser maybe
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-EDIT" "3" "January 2012" "" ""
+.TH "NPM\-EDIT" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-edit\fR \-\- Edit an installed package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-EXPLORE" "3" "January 2012" "" ""
+.TH "NPM\-EXPLORE" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-explore\fR \-\- Browse an installed package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-HELP\-SEARCH" "3" "January 2012" "" ""
+.TH "NPM\-HELP\-SEARCH" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-help-search\fR \-\- Search the help pages
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "INIT" "3" "January 2012" "" ""
+.TH "INIT" "3" "May 2012" "" ""
.
.SH "NAME"
\fBinit\fR \-\- Interactively create a package\.json file
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-INSTALL" "3" "January 2012" "" ""
+.TH "NPM\-INSTALL" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-install\fR \-\- install a package programmatically
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-LINK" "3" "January 2012" "" ""
+.TH "NPM\-LINK" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-link\fR \-\- Symlink a package folder
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-LOAD" "3" "January 2012" "" ""
+.TH "NPM\-LOAD" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-load\fR \-\- Load config settings
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-LS" "3" "January 2012" "" ""
+.TH "NPM\-LS" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-ls\fR \-\- List installed packages
If the silent parameter is set to true, nothing will be output to the screen,
but the data will still be returned\.
.
+.P
+Callback is provided an error if one occurred, the full data about which
+packages are installed and which dependencies they will receive, and a
+"lite" data object which just shows which versions are installed where\.
+Note that the full data object is a circular structure, so care must be
+taken if it is serialized to JSON\.
+.
.SH "CONFIGURATION"
.
.SS "long"
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM" "3" "January 2012" "" ""
+.TH "NPM" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm\fR \-\- node package manager
.fi
.
.SH "VERSION"
-1.1.0-2
+1.1.21
.
.SH "DESCRIPTION"
This is the API documentation for npm\.
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-OUTDATED" "3" "January 2012" "" ""
+.TH "NPM\-OUTDATED" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-outdated\fR \-\- Check for outdated packages
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-OWNER" "3" "January 2012" "" ""
+.TH "NPM\-OWNER" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-owner\fR \-\- Manage package owners
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-PACK" "3" "January 2012" "" ""
+.TH "NPM\-PACK" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-pack\fR \-\- Create a tarball from a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-PREFIX" "3" "January 2012" "" ""
+.TH "NPM\-PREFIX" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-prefix\fR \-\- Display prefix
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-PRUNE" "3" "January 2012" "" ""
+.TH "NPM\-PRUNE" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-prune\fR \-\- Remove extraneous packages
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-PUBLISH" "3" "January 2012" "" ""
+.TH "NPM\-PUBLISH" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-publish\fR \-\- Publish a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-REBUILD" "3" "January 2012" "" ""
+.TH "NPM\-REBUILD" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-rebuild\fR \-\- Rebuild a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-RESTART" "3" "January 2012" "" ""
+.TH "NPM\-RESTART" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-restart\fR \-\- Start a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-ROOT" "3" "January 2012" "" ""
+.TH "NPM\-ROOT" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-root\fR \-\- Display npm root
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-RUN\-SCRIPT" "3" "January 2012" "" ""
+.TH "NPM\-RUN\-SCRIPT" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-run-script\fR \-\- Run arbitrary package scripts
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-SEARCH" "3" "January 2012" "" ""
+.TH "NPM\-SEARCH" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-search\fR \-\- Search for packages
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-SHRINKWRAP" "3" "April 2012" "" ""
+.TH "NPM\-SHRINKWRAP" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-shrinkwrap\fR \-\- programmatically generate package shrinkwrap file
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-START" "3" "January 2012" "" ""
+.TH "NPM\-START" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-start\fR \-\- Start a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-STOP" "3" "January 2012" "" ""
+.TH "NPM\-STOP" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-stop\fR \-\- Stop a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-SUBMODULE" "3" "January 2012" "" ""
+.TH "NPM\-SUBMODULE" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-submodule\fR \-\- Add a package as a git submodule
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-TAG" "3" "January 2012" "" ""
+.TH "NPM\-TAG" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-tag\fR \-\- Tag a published version
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-TEST" "3" "January 2012" "" ""
+.TH "NPM\-TEST" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-test\fR \-\- Test a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-UNINSTALL" "3" "January 2012" "" ""
+.TH "NPM\-UNINSTALL" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-uninstall\fR \-\- uninstall a package programmatically
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-UNPUBLISH" "3" "January 2012" "" ""
+.TH "NPM\-UNPUBLISH" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-unpublish\fR \-\- Remove a package from the registry
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-UPDATE" "3" "January 2012" "" ""
+.TH "NPM\-UPDATE" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-update\fR \-\- Update a package
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-VERSION" "3" "January 2012" "" ""
+.TH "NPM\-VERSION" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-version\fR \-\- Bump a package version
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-VIEW" "3" "January 2012" "" ""
+.TH "NPM\-VIEW" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-view\fR \-\- View registry info
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
-.TH "NPM\-WHOAMI" "3" "January 2012" "" ""
+.TH "NPM\-WHOAMI" "3" "May 2012" "" ""
.
.SH "NAME"
\fBnpm-whoami\fR \-\- Display npm username
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"name": "block-stream",
"description": "a stream of blocks",
- "version": "0.0.4",
+ "version": "0.0.5",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/block-stream.git"
},
"engines": {
- "node": "0.4 || ~0.5.8 || 0.6"
+ "node": "0.4 || ~0.5.8 || 0.6 || 0.7"
},
"main": "block-stream.js",
"dependencies": {
+++ /dev/null
-node_modules/
+++ /dev/null
-language: node_js
-node_js:
- - 0.4
- - 0.6
+++ /dev/null
-# The Problem
-
-You've got some thing where you need to push a bunch of stuff into a
-queue and then shift it out. Or, maybe it's a stack, and you're just
-pushing and popping it.
-
-Arrays work for this, but are a bit costly performance-wise.
-
-# The Solution
-
-A linked-list implementation that takes advantage of what v8 is good at:
-creating objects with a known shape.
-
-This is faster for this use case. How much faster? About 50%.
-
- $ node bench.js
- benchmarking /Users/isaacs/dev-src/js/fast-list/bench.js
- Please be patient.
- { node: '0.6.2-pre',
- v8: '3.6.6.8',
- ares: '1.7.5-DEV',
- uv: '0.1',
- openssl: '0.9.8l' }
- Scores: (bigger is better)
-
- new FastList()
- Raw:
- > 22556.39097744361
- > 23054.755043227666
- > 22770.398481973436
- > 23414.634146341465
- > 23099.133782483157
- Average (mean) 22979.062486293868
-
- []
- Raw:
- > 12195.121951219513
- > 12184.508268059182
- > 12173.91304347826
- > 12216.404886561955
- > 12184.508268059182
- Average (mean) 12190.891283475617
-
- new Array()
- Raw:
- > 12131.715771230503
- > 12184.508268059182
- > 12216.404886561955
- > 12195.121951219513
- > 11940.298507462687
- Average (mean) 12133.609876906768
-
- Winner: new FastList()
- Compared with next highest ([]), it's:
- 46.95% faster
- 1.88 times as fast
- 0.28 order(s) of magnitude faster
-
- Compared with the slowest (new Array()), it's:
- 47.2% faster
- 1.89 times as fast
- 0.28 order(s) of magnitude faster
-
-This lacks a lot of features that arrays have:
-
-1. You can't specify the size at the outset.
-2. It's not indexable.
-3. There's no join, concat, etc.
-
-If any of this matters for your use case, you're probably better off
-using an Array object.
-
-## Installing
-
-```
-npm install fast-list
-```
-
-## API
-
-```javascript
-var FastList = require("fast-list")
-var list = new FastList()
-list.push("foo")
-list.unshift("bar")
-list.push("baz")
-console.log(list.length) // 2
-console.log(list.pop()) // baz
-console.log(list.shift()) // bar
-console.log(list.shift()) // foo
-```
-
-### Methods
-
-* `push`: Just like Array.push, but only can take a single entry
-* `pop`: Just like Array.pop
-* `shift`: Just like Array.shift
-* `unshift`: Just like Array.unshift, but only can take a single entry
-* `drop`: Drop all entries
-* `item(n)`: Retrieve the nth item in the list. This involves a walk
- every time. It's very slow. If you find yourself using this,
- consider using a normal Array instead.
-* `map(fn, thisp)`: Like `Array.prototype.map`. Returns a new FastList.
-* `reduce(fn, startValue, thisp)`: Like `Array.prototype.reduce`
-* `forEach(fn, this)`: Like `Array.prototype.forEach`
-* `filter(fn, thisp)`: Like `Array.prototype.filter`. Returns a new
- FastList.
-* `slice(start, end)`: Retrieve an array of the items at this position.
- This involves a walk every time. It's very slow. If you find
- yourself using this, consider using a normal Array instead.
-
-### Members
-
-* `length`: The number of things in the list. Note that, unlike
- Array.length, this is not a getter/setter, but rather a counter that
- is internally managed. Setting it can only cause harm.
+++ /dev/null
-;(function() { // closure for web browsers
-
-function Item (data, prev, next) {
- this.next = next
- if (next) next.prev = this
- this.prev = prev
- if (prev) prev.next = this
- this.data = data
-}
-
-function FastList () {
- if (!(this instanceof FastList)) return new FastList
- this._head = null
- this._tail = null
- this.length = 0
-}
-
-FastList.prototype =
-{ push: function (data) {
- this._tail = new Item(data, this._tail, null)
- if (!this._head) this._head = this._tail
- this.length ++
- }
-
-, pop: function () {
- if (this.length === 0) return undefined
- var t = this._tail
- this._tail = t.prev
- if (t.prev) {
- t.prev = this._tail.next = null
- }
- this.length --
- if (this.length === 1) this._head = this._tail
- else if (this.length === 0) this._head = this._tail = null
- return t.data
- }
-
-, unshift: function (data) {
- this._head = new Item(data, null, this._head)
- if (!this._tail) this._tail = this._head
- this.length ++
- }
-
-, shift: function () {
- if (this.length === 0) return undefined
- var h = this._head
- this._head = h.next
- if (h.next) {
- h.next = this._head.prev = null
- }
- this.length --
- if (this.length === 1) this._tail = this._head
- else if (this.length === 0) this._head = this._tail = null
- return h.data
- }
-
-, item: function (n) {
- if (n < 0) n = this.length + n
- var h = this._head
- while (n-- > 0 && h) h = h.next
- return h ? h.data : undefined
- }
-
-, slice: function (n, m) {
- if (!n) n = 0
- if (!m) m = this.length
- if (m < 0) m = this.length + m
- if (n < 0) n = this.length + n
-
- if (m === n) {
- return []
- }
-
- if (m < n) {
- throw new Error("invalid offset: "+n+","+m+" (length="+this.length+")")
- }
-
- var len = m - n
- , ret = new Array(len)
- , i = 0
- , h = this._head
- while (n-- > 0 && h) h = h.next
- while (i < len && h) {
- ret[i++] = h.data
- h = h.next
- }
- return ret
- }
-
-, drop: function () {
- FastList.call(this)
- }
-
-, forEach: function (fn, thisp) {
- var p = this._head
- , i = 0
- , len = this.length
- while (i < len && p) {
- fn.call(thisp || this, p.data, i, this)
- p = p.next
- i ++
- }
- }
-
-, map: function (fn, thisp) {
- var n = new FastList()
- this.forEach(function (v, i, me) {
- n.push(fn.call(thisp || me, v, i, me))
- })
- return n
- }
-
-, filter: function (fn, thisp) {
- var n = new FastList()
- this.forEach(function (v, i, me) {
- if (fn.call(thisp || me, v, i, me)) n.push(v)
- })
- return n
- }
-
-, reduce: function (fn, val, thisp) {
- var i = 0
- , p = this._head
- , len = this.length
- if (!val) {
- i = 1
- val = p && p.data
- p = p && p.next
- }
- while (i < len && p) {
- val = fn.call(thisp || this, val, p.data, this)
- i ++
- p = p.next
- }
- return val
- }
-}
-
-if ("undefined" !== typeof(exports)) module.exports = FastList
-else if ("function" === typeof(define) && define.amd) {
- define("FastList", function() { return FastList })
-} else (function () { return this })().FastList = FastList
-
-})()
+++ /dev/null
-{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
- "name": "fast-list",
- "description": "A fast linked list (good for queues, stacks, etc.)",
- "version": "1.0.2",
- "repository": {
- "type": "git",
- "url": "git://github.com/isaacs/fast-list.git"
- },
- "main": "fast-list.js",
- "dependencies": {},
- "devDependencies": {
- "bench": "~0.3.2",
- "tap": "~0.1.0"
- },
- "scripts": {
- "test": "tap test.js",
- "bench": "node bench.js"
- }
-}
.*.swp
-examples/deep-copy
node_modules/
+examples/deep-copy/
+examples/path/
+examples/filter-copy/
return this
}
+Abstract.prototype.abort = function () {
+ this._aborted = true
+ this.emit("abort")
+}
+
Abstract.prototype.destroy = function () {}
Abstract.prototype.warn = function (msg, code) {
, mkdir = require("mkdirp")
, path = require("path")
, Reader = require("./reader.js")
+ , assert = require("assert").ok
inherits(DirReader, Reader)
throw new Error("Non-directory type "+ props.type)
}
- me._entries = null
+ me.entries = null
me._index = -1
me._paused = false
me._length = -1
+ if (props.sort) {
+ this.sort = props.sort
+ }
+
Reader.call(this, props)
}
DirReader.prototype._getEntries = function () {
var me = this
+
+ // race condition. might pause() before calling _getEntries,
+ // and then resume, and try to get them a second time.
+ if (me._gotEntries) return
+ me._gotEntries = true
+
fs.readdir(me._path, function (er, entries) {
if (er) return me.error(er)
- me._entries = entries
- me._length = entries.length
- // console.error("DR %s sort =", me.path, me.props.sort)
- if (typeof me.props.sort === "function") {
- me._entries.sort(me.props.sort)
+
+ me.entries = entries
+
+ me.emit("entries", entries)
+ if (me._paused) me.once("resume", processEntries)
+ else processEntries()
+
+ function processEntries () {
+ me._length = me.entries.length
+ if (typeof me.sort === "function") {
+ me.entries = me.entries.sort(me.sort.bind(me))
+ }
+ me._read()
}
- me._read()
})
}
DirReader.prototype._read = function () {
var me = this
- if (!me._entries) return me._getEntries()
+ if (!me.entries) return me._getEntries()
if (me._paused || me._currentEntry || me._aborted) {
// console.error("DR paused=%j, current=%j, aborted=%j", me._paused, !!me._currentEntry, me._aborted)
}
me._index ++
- if (me._index >= me._length) {
+ if (me._index >= me.entries.length) {
if (!me._ended) {
me._ended = true
me.emit("end")
// ok, handle this one, then.
// save creating a proxy, by stat'ing the thing now.
- var p = path.resolve(me._path, me._entries[me._index])
+ var p = path.resolve(me._path, me.entries[me._index])
+ assert(p !== me._path)
+ assert(me.entries[me._index])
+
// set this to prevent trying to _read() again in the stat time.
me._currentEntry = p
fs[ me.props.follow ? "stat" : "lstat" ](p, function (er, stat) {
if (er) return me.error(er)
- var entry = Reader({ path: p
- , depth: me.depth + 1
- , root: me.root || me._proxy || me
- , parent: me._proxy || me
- , follow: me.follow
- , filter: me.filter
- , sort: me.props.sort
- }, stat)
+ var who = me._proxy || me
+
+ stat.path = p
+ stat.basename = path.basename(p)
+ stat.dirname = path.dirname(p)
+ var childProps = me.getChildProps.call(who, stat)
+ childProps.path = p
+ childProps.basename = path.basename(p)
+ childProps.dirname = path.dirname(p)
+
+ var entry = Reader(childProps, stat)
// console.error("DR Entry", p, stat.size)
// This nomenclature is not completely final.
entry.on("pause", function (who) {
- if (!me._paused) {
+ if (!me._paused && !entry._disowned) {
me.pause(who)
}
})
entry.on("resume", function (who) {
- if (me._paused) {
+ if (me._paused && !entry._disowned) {
me.resume(who)
}
})
+ entry.on("stat", function (props) {
+ me.emit("_entryStat", entry, props)
+ if (entry._aborted) return
+ if (entry._paused) entry.once("resume", function () {
+ me.emit("entryStat", entry, props)
+ })
+ })
+
entry.on("ready", function EMITCHILD () {
// console.error("DR emit child", entry._path)
if (me._paused) {
if (entry.type === "Socket") {
me.emit("socket", entry)
} else {
- me.emit("entry", entry)
- me.emit("child", entry)
+ me.emitEntry(entry)
}
})
var ended = false
entry.on("close", onend)
+ entry.on("disown", onend)
function onend () {
if (ended) return
ended = true
me.emit("childEnd", entry)
me.emit("entryEnd", entry)
me._currentEntry = null
- me._read()
+ if (!me._paused) {
+ me._read()
+ }
}
- // XXX Make this work in node.
+ // XXX Remove this. Works in node as of 0.6.2 or so.
// Long filenames should not break stuff.
entry.on("error", function (er) {
if (entry._swallowErrors) {
})
}
+DirReader.prototype.disown = function (entry) {
+ entry.emit("beforeDisown")
+ entry._disowned = true
+ entry.parent = entry.root = null
+ if (entry === this._currentEntry) {
+ this._currentEntry = null
+ }
+ entry.emit("disown")
+}
+
+DirReader.prototype.getChildProps = function (stat) {
+ return { depth: this.depth + 1
+ , root: this.root || this
+ , parent: this
+ , follow: this.follow
+ , filter: this.filter
+ , sort: this.props.sort
+ }
+}
+
DirReader.prototype.pause = function (who) {
var me = this
if (me._paused) return
}
if (me._currentEntry) {
- if (me._currentEntry.resume) {
- me._currentEntry.resume(who)
- }
+ if (me._currentEntry.resume) me._currentEntry.resume(who)
} else me._read()
}
+
+DirReader.prototype.emitEntry = function (entry) {
+ this.emit("entry", entry)
+ this.emit("child", entry)
+}
// ready to start getting entries!
me.ready = true
me.emit("ready")
+ me._process()
})
}
// don't allow recursive copying
var p = entry
do {
- if (p._path === me.root._path || p._path === me._path) {
+ var pp = p._path || p.path
+ if (pp === me.root._path || pp === me._path ||
+ (pp && pp.indexOf(me._path) === 0)) {
// console.error("DW Exit (recursive)", entry.basename, me._path)
me._processing = false
if (entry._collected) entry.pipe()
// get rid of any ../../ shenanigans
props.path = path.join(me.path, path.join("/", p))
+ // if i have a filter, the child should inherit it.
+ props.filter = me.filter
+
// all the rest of the stuff, copy over from the source.
Object.keys(entry.props).forEach(function (k) {
if (!props.hasOwnProperty(k)) {
var fs = require("graceful-fs")
, Writer = require("./writer.js")
, inherits = require("inherits")
- , collect = require("./collect.js")
, path = require("path")
, rimraf = require("rimraf")
, "close"
, "linkpath"
, "entry"
+ , "entryEnd"
+ , "child"
+ , "childEnd"
, "warn"
+ , "stat"
].forEach(function (ev) {
// console.error("~~ proxy event", ev, me.path)
proxy.on(ev, me.emit.bind(me, ev))
// if the filter doesn't pass, then just skip over this one.
// still have to emit end so that dir-walking can move on.
if (me.filter) {
+ var who = me._proxy || me
// special handling for ProxyReaders
- if (!me.filter.call(me._proxy || me)) {
- me._aborted = true
+ if (!me.filter.call(who, who, props)) {
+ if (!me._disowned) {
+ me.abort()
+ me.emit("end")
+ me.emit("close")
+ }
+ return
+ }
+ }
+
+ // last chance to abort or disown before the flow starts!
+ var events = ["_stat", "stat", "ready"]
+ var e = 0
+ ;(function go () {
+ if (me._aborted) {
me.emit("end")
me.emit("close")
return
}
- }
- me.emit("ready", props)
+ if (me._paused) {
+ me.once("resume", go)
+ return
+ }
- // if it's a directory, then we'll be emitting "entry" events.
- me._read()
+ var ev = events[e ++]
+ if (!ev) return me._read()
+ me.emit(ev, props)
+ go()
+ })()
}
}
me._buffer = []
me.ready = false
+ me.filter = typeof props.filter === "function" ? props.filter: null
+
// start the ball rolling.
// this checks what's there already, and then calls
// me._create() to call the impl-specific creation stuff.
var me = this
, props = me.props
, stat = props.follow ? "stat" : "lstat"
+ , who = me._proxy || me
if (current) statCb(null, current)
else fs[stat](me._path, statCb)
function statCb (er, current) {
+ if (me.filter && !me.filter.call(who, who, current)) {
+ me._aborted = true
+ me.emit("end")
+ me.emit("close")
+ return
+ }
+
// if it's not there, great. We'll just create it.
// if it is there, then we'll need to change whatever differs
if (er || !current) {
// XXX Need to clobber non-dirs that are in the way,
// unless { clobber: false } in the props.
- mkdir(path.dirname(me._path), Writer.dirmode, function (er) {
+ mkdir(path.dirname(me._path), Writer.dirmode, function (er, made) {
// console.error("W created", path.dirname(me._path), er)
if (er) return me.error(er)
- me._create()
+
+ // later on, we have to set the mode and owner for these
+ me._madeDir = made
+ return me._create()
})
}
+function endChmod (me, want, current, path, cb) {
+ var wantMode = want.mode
+ , chmod = want.follow || me.type !== "SymbolicLink"
+ ? "chmod" : "lchmod"
+
+ if (!fs[chmod]) return cb()
+ if (typeof wantMode !== "number") return cb()
+
+ var curMode = current.mode & 0777
+ wantMode = wantMode & 0777
+ if (wantMode === curMode) return cb()
+
+ fs[chmod](path, wantMode, cb)
+}
+
+
+function endChown (me, want, current, path, cb) {
+ // Don't even try it unless root. Too easy to EPERM.
+ if (process.platform === "win32") return cb()
+ if (!process.getuid || !process.getuid() === 0) return cb()
+ if (typeof want.uid !== "number" &&
+ typeof want.gid !== "number" ) return cb()
+
+ if (current.uid === want.uid &&
+ current.gid === want.gid) return cb()
+
+ var chown = (me.props.follow || me.type !== "SymbolicLink")
+ ? "chown" : "lchown"
+ if (!fs[chown]) return cb()
+
+ if (typeof want.uid !== "number") want.uid = current.uid
+ if (typeof want.gid !== "number") want.gid = current.gid
+
+ fs[chown](path, want.uid, want.gid, cb)
+}
+
+function endUtimes (me, want, current, path, cb) {
+ if (!fs.utimes || process.platform === "win32") return cb()
+
+ var utimes = (want.follow || me.type !== "SymbolicLink")
+ ? "utimes" : "lutimes"
+
+ if (utimes === "lutimes" && !fs[utimes]) {
+ utimes = "utimes"
+ }
+
+ if (!fs[utimes]) return cb()
+
+ var curA = current.atime
+ , curM = current.mtime
+ , meA = want.atime
+ , meM = want.mtime
+
+ if (meA === undefined) meA = curA
+ if (meM === undefined) meM = curM
+
+ if (!isDate(meA)) meA = new Date(meA)
+ if (!isDate(meM)) meA = new Date(meM)
+
+ if (meA.getTime() === curA.getTime() &&
+ meM.getTime() === curM.getTime()) return cb()
+
+ fs[utimes](path, meA, meM, cb)
+}
+
+
+// XXX This function is beastly. Break it up!
Writer.prototype._finish = function () {
var me = this
return
function setProps (current) {
- // console.error(" W setprops", me._path)
- // mode
- var wantMode = me.props.mode
- , chmod = me.props.follow || me.type !== "SymbolicLink"
- ? "chmod" : "lchmod"
-
- if (fs[chmod] && typeof wantMode === "number") {
- wantMode = wantMode & 0777
- todo ++
- // console.error(" W chmod", wantMode.toString(8), me.basename, "\r")
- fs[chmod](me._path, wantMode, next(chmod))
- }
+ endChmod(me, me.props, current, me._path, next("chmod"))
+ endChown(me, me.props, current, me._path, next("chown"))
+ endUtimes(me, me.props, current, me._path, next("chown"))
+ }
- // uid, gid
- // Don't even try it unless root. Too easy to EPERM.
- if (process.platform !== "win32" &&
- process.getuid && process.getuid() === 0 &&
- ( typeof me.props.uid === "number" ||
- typeof me.props.gid === "number" )) {
- var chown = (me.props.follow || me.type !== "SymbolicLink")
- ? "chown" : "lchown"
- if (fs[chown]) {
- if (typeof me.props.uid !== "number") me.props.uid = current.uid
- if (typeof me.props.gid !== "number") me.props.gid = current.gid
- if (me.props.uid !== current.uid || me.props.gid !== current.gid) {
- todo ++
- // console.error(" W chown", me.props.uid, me.props.gid, me.basename)
- fs[chown](me._path, me.props.uid, me.props.gid, next("chown"))
+ function next (what) {
+ todo ++
+ return function (er) {
+ // console.error(" W Finish", what, todo)
+ if (errState) return
+ if (er) {
+ er.fstream_finish_call = what
+ return me.error(errState = er)
+ }
+ if (--todo > 0) return
+ if (done) return
+ done = true
+
+ // we may still need to set the mode/etc. on some parent dirs
+ // that were created previously. delay end/close until then.
+ if (!me._madeDir) return end()
+ else endMadeDir(me, me._path, end)
+
+ function end (er) {
+ if (er) {
+ er.fstream_finish_call = "setupMadeDir"
+ return me.error(er)
}
+ // all the props have been set, so we're completely done.
+ me.emit("end")
+ me.emit("close")
}
}
+ }
+}
- // atime, mtime.
- if (fs.utimes && process.platform !== "win32") {
- var utimes = (me.props.follow || me.type !== "SymbolicLink")
- ? "utimes" : "lutimes"
-
- if (utimes === "lutimes" && !fs[utimes]) {
- utimes = "utimes"
- }
-
- var curA = current.atime
- , curM = current.mtime
- , meA = me.props.atime
- , meM = me.props.mtime
+function endMadeDir (me, p, cb) {
+ var made = me._madeDir
+ // everything *between* made and path.dirname(me._path)
+ // needs to be set up. Note that this may just be one dir.
+ var d = path.dirname(p)
- if (meA === undefined) meA = curA
- if (meM === undefined) meM = curM
+ endMadeDir_(me, d, function (er) {
+ if (er) return cb(er)
+ if (d === made) {
+ return cb()
+ }
+ endMadeDir(me, d, cb)
+ })
+}
- if (!isDate(meA)) meA = new Date(meA)
- if (!isDate(meM)) meA = new Date(meM)
+function endMadeDir_ (me, p, cb) {
+ var dirProps = {}
+ Object.keys(me.props).forEach(function (k) {
+ dirProps[k] = me.props[k]
- if (meA.getTime() !== curA.getTime() ||
- meM.getTime() !== curM.getTime()) {
- todo ++
- // console.error(" W utimes", meA, meM, me.basename)
- fs[utimes](me._path, meA, meM, next("utimes"))
- }
+ // only make non-readable dirs if explicitly requested.
+ if (k === "mode" && me.type !== "Directory") {
+ dirProps[k] = dirProps[k] | 0111
}
+ })
- // finally, handle the case if there was nothing to do.
- if (todo === 0) {
- // console.error(" W nothing to do", me.basename)
- next("nothing to do")()
- }
- }
+ var todo = 3
+ , errState = null
+ fs.stat(p, function (er, current) {
+ if (er) return cb(errState = er)
+ endChmod(me, dirProps, current, p, next)
+ endChown(me, dirProps, current, p, next)
+ endUtimes(me, dirProps, current, p, next)
+ })
- function next (what) { return function (er) {
- // console.error(" W Finish", what, todo)
+ function next (er) {
if (errState) return
- if (er) {
- er.fstream_finish_call = what
- return me.error(errState = er)
- }
- if (--todo > 0) return
- if (done) return
- done = true
-
- // all the props have been set, so we're completely done.
- me.emit("end")
- me.emit("close")
- }}
+ if (er) return cb(errState = er)
+ if (-- todo === 0) return cb()
+ }
}
Writer.prototype.pipe = function () {
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
"name": "fstream",
"description": "Advanced file system stream things",
- "version": "0.1.11",
+ "version": "0.1.18",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/fstream.git"
},
"main": "fstream.js",
"engines": {
- "node": "0.5 || 0.6 || 0.7"
+ "node": ">=0.6"
},
"dependencies": {
- "rimraf": "~1.0.8",
- "mkdirp": "~0.1.0",
+ "rimraf": "2",
+ "mkdirp": "0.3",
"graceful-fs": "~1.1.2",
"inherits": "~1.0.0"
},
"devDependencies": {
- "tap": "0.1"
+ "tap": ""
},
"scripts": {
"test": "tap examples/*.js"
- }
+ },
+ "license": "BSD",
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "fstream@0.1.18",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.13",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "_from": "fstream@~0.1.17"
}
// there is such a thing as TOO graceful.
if (fs.open === gracefulOpen) return
-var FastList = require("fast-list")
- , queue = new FastList()
+var queue = []
, curOpen = 0
, constants = require("constants")
fs.lutimesSync = function () {}
}
}
+
+
+// https://github.com/isaacs/node-graceful-fs/issues/4
+// Chown should not fail on einval or eperm if non-root.
+
+fs.chown = chownFix(fs.chown)
+fs.fchown = chownFix(fs.fchown)
+fs.lchown = chownFix(fs.lchown)
+
+fs.chownSync = chownFixSync(fs.chownSync)
+fs.fchownSync = chownFixSync(fs.fchownSync)
+fs.lchownSync = chownFixSync(fs.lchownSync)
+
+function chownFix (orig) {
+ if (!orig) return orig
+ return function (target, uid, gid, cb) {
+ return orig.call(fs, target, uid, gid, function (er, res) {
+ if (chownErOk(er)) er = null
+ cb(er, res)
+ })
+ }
+}
+
+function chownFixSync (orig) {
+ if (!orig) return orig
+ return function (target, uid, gid) {
+ try {
+ return orig.call(fs, target, uid, gid)
+ } catch (er) {
+ if (!chownErOk(er)) throw er
+ }
+ }
+}
+
+function chownErOk (er) {
+ // if there's no getuid, or if getuid() is something other than 0,
+ // and the error is EINVAL or EPERM, then just ignore it.
+ // This specific case is a silent failure in cp, install, tar,
+ // and most other unix tools that manage permissions.
+ // When running as root, or if other types of errors are encountered,
+ // then it's strict.
+ if (!er || (!process.getuid || process.getuid() !== 0)
+ && (er.code === "EINVAL" || er.code === "EPERM")) return true
+}
+
+
+
+// on Windows, A/V software can lock the directory, causing this
+// to fail with an EACCES or EPERM if the directory contains newly
+// created files. Try again on failure, for up to 1 second.
+if (process.platform === "win32") {
+ var rename_ = fs.rename
+ fs.rename = function rename (from, to, cb) {
+ var start = Date.now()
+ rename_(from, to, function CB (er) {
+ if (er
+ && (er.code === "EACCES" || er.code === "EPERM")
+ && Date.now() - start < 1000) {
+ return rename_(from, to, CB)
+ }
+ cb(er)
+ })
+ }
+}
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me"
+ },
"name": "graceful-fs",
"description": "fs monkey-patching to avoid EMFILE and other problems",
- "version": "1.1.2",
+ "version": "1.1.8",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-graceful-fs.git"
},
"main": "graceful-fs.js",
"engines": {
- "node": "0.4 || 0.5 || 0.6"
+ "node": ">=0.4.0"
},
- "dependencies": {
- "fast-list": "1"
+ "devDependencies": {},
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
},
- "devDependencies": {}
+ "_id": "graceful-fs@1.1.8",
+ "dependencies": {},
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.10",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "_from": "graceful-fs@~1.1.1"
}
-Copyright 2011 Isaac Z. Schlueter (the "Author")
-All rights reserved.
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
-General Public Obviousness License
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
-The Author asserts that this software and associated documentation
-files (the "Software"), while the Author's original creation, is
-nonetheless obvious, trivial, unpatentable, and implied by the
-context in which the software was created. If you sat down and
-thought about the problem for an hour or less, you'd probably
-come up with exactly this solution.
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
-Permission is granted to use this software in any way
-whatsoever, with the following restriction:
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-You may not release the Software under a more restrictive license
-than this one.
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-{ "name" : "inherits"
-, "description": "A tiny simple way to do classic inheritance in js"
-, "version" : "1.0.0"
-, "keywords" : ["inheritance", "class", "klass", "oop", "object-oriented"]
-, "main" : "./inherits.js"
-, "repository" : "https://github.com/isaacs/inherits"
-, "license": { "type": "GPOL", "url": "https://raw.github.com/isaacs/inherits/master/LICENSE" }
-, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)" }
+{
+ "name": "inherits",
+ "description": "A tiny simple way to do classic inheritance in js",
+ "version": "1.0.0",
+ "keywords": [
+ "inheritance",
+ "class",
+ "klass",
+ "oop",
+ "object-oriented"
+ ],
+ "main": "./inherits.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/inherits.git"
+ },
+ "license": {
+ "type": "WTFPL2"
+ },
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "inherits@1.0.0",
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "_engineSupported": true,
+ "_npmVersion": "1.1.10",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "12dbc03c9f7c203289234b214a7d05a311d71450"
+ },
+ "_from": "git://github.com/isaacs/inherits"
+}
`a/**b` will not. **Note that this is different from the way that `**` is
handled by ruby's `Dir` class.**
-If an escaped pattern has no matches, and the `null` flag is not set,
+If an escaped pattern has no matches, and the `nonull` flag is set,
then minimatch.match returns the pattern as-provided, rather than
interpreting the character escapes. For example,
`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
-`"*a?"`.
+`"*a?"`. This is akin to setting the `nullglob` option in bash, except
+that it does not resolve escaped pattern characters.
If brace expansion is not disabled, then it is performed before any
other interpretation of the glob pattern. Thus, a pattern like
### minimatch.match(list, pattern, options)
Match against the list of
-files, in the style of fnmatch or glob. If nothing is matched, then
-return the pattern (unless `{ null: true }` in the options.)
+files, in the style of fnmatch or glob. If nothing is matched, and
+options.nonull is set, then return a list containing the pattern itself.
```javascript
var javascripts = minimatch.match(fileList, "*.js", {matchBase: true}))
### nonegate
Suppress the behavior of treating a leading `!` character as negation.
+
+### flipNegate
+
+Returns from negate expressions the same as if they were not negated.
+(Ie, true on a hit, false on a miss.)
var LRU = require("lru-cache")
, cache = minimatch.cache = new LRU(100)
, GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
- , pathSplit = process.platform === "win32" ? /\\|\// : "/"
var path = require("path")
// any single thing other than /
this.parseNegate()
// step 2: expand braces
- var set = this.braceExpand()
+ var set = this.globSet = this.braceExpand()
if (options.debug) console.error(this.pattern, set)
// These will be regexps, except in the case of "**", which is
// set to the GLOBSTAR object for globstar behavior,
// and will not contain any / characters
- set = set.map(function (s) {
+ set = this.globParts = set.map(function (s) {
return s.split(slashSplit)
})
- // step 4: if we have a defined root, then patterns starting with ""
- // get attached to that. If we have a defined cwd, then patterns
- // *not* starting with "" get attached to that.
- // Exception 1: on windows, a pattern like //\?/c:/ or c:/ will
- // not get anything prefixed to it.
- // Exception 2: If matchBase is set, and it's just a filename,
- // then don't prefix anything onto it, since it'll only match
- // files with that basename anyhow.
- set = set.map(function (p) {
- if (process.platform === "win32" &&
- ( (p[0] === "" && p[1] === "" && p[2] === "\\?") // unc
- || (p[0].match(/^[a-zA-Z]:$/)) )) {
- return p
- }
- if (options.matchBase && p.length === 1) return p
- // do prefixing.
- if (options.root && p[0] === "") {
- return options.root.split(pathSplit).concat(p)
- }
- if (options.cwd && p[0] !== "") {
- return options.cwd.split(pathSplit).concat(p)
- }
- return p
- })
-
-
if (options.debug) console.error(this.pattern, set)
// glob --> regexps
patternListStack.push({ type: plType
, start: i - 1
, reStart: re.length })
- re += stateChar === "!" ? "(?!" : "(?:"
+ // negation is (?:(?!js)[^/]*)
+ re += stateChar === "!" ? "(?:(?!" : "(?:"
stateChar = false
continue
hasMagic = true
re += ")"
plType = patternListStack.pop().type
+ // negation is (?:(?!js)[^/]*)
+ // The others are (?:<pattern>)<type>
switch (plType) {
+ case "!":
+ re += "[^/]*?)"
+ break
case "?":
case "+":
case "*": re += plType
- case "!": // already handled by the start
case "@": break // the default anyway
}
continue
if (this.comment) return false
if (this.empty) return f === ""
+ if (f === "/" && partial) return true
+
var options = this.options
// first, normalize any slash-separated path parts.
// f = path.normalize(f)
- var absolute = isAbsolute(f)
-
- // console.error(this.pattern, f, absolute)
// windows: need to use /, not \
// On other platforms, \ is a valid (albeit bad) filename char.
// treat the test path as a set of pathparts.
f = f.split(slashSplit)
- // console.error(this.pattern, "split", f)
+ if (options.debug) {
+ console.error(this.pattern, "split", f)
+ }
// just ONE of the pattern sets in this.set needs to match
// in order for it to be valid. If negating, then just one
var pattern = set[i]
var hit = this.matchOne(f, pattern, partial)
if (hit) {
+ if (options.flipNegate) return true
return !this.negate
}
}
// didn't get any hits. this is success if it's a negative
// pattern, failure otherwise.
+ if (options.flipNegate) return false
return this.negate
}
function regExpEscape (s) {
return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
}
-
-
-function isAbsolute (p) {
- if (process.platform !== "win32") return p.charAt(0) === "/"
-
- // yanked from node/lib/path.js
- var splitDeviceRe =
- /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/
-
- var result = p.match(splitDeviceRe)
- , device = result[1] || ""
- , isUnc = device && device.charAt(1) !== ":"
- , isAbs = !!result[2] || isUnc // UNC always absolute
-
- return isAbs
-}
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me"
+ },
"name": "minimatch",
"description": "a glob matcher in javascript",
- "version": "0.1.3",
+ "version": "0.2.2",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/minimatch.git"
"lru-cache": "~1.0.5"
},
"devDependencies": {
- "tap": "~0.1.3"
+ "tap": ""
},
- "licenses" : [
+ "licenses": [
{
- "type" : "MIT",
- "url" : "http://github.com/isaacs/minimatch/raw/master/LICENSE"
+ "type": "MIT",
+ "url": "http://github.com/isaacs/minimatch/raw/master/LICENSE"
}
- ]
+ ],
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "minimatch@0.2.2",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.12",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "_from": "minimatch@0"
}
Like `mkdir -p`, but in node.js!
-Example
+example
=======
pow.js
------
var mkdirp = require('mkdirp');
- mkdirp('/tmp/foo/bar/baz', 0755, function (err) {
+ mkdirp('/tmp/foo/bar/baz', function (err) {
if (err) console.error(err)
else console.log('pow!')
});
pow!
And now /tmp/foo/bar/baz exists, huzzah!
+
+methods
+=======
+
+var mkdirp = require('mkdirp');
+
+mkdirp(dir, mode, cb)
+---------------------
+
+Create a new directory and any necessary subdirectories at `dir` with octal
+permission string `mode`.
+
+If `mode` isn't specified, it defaults to `0777 & (~process.umask())`.
+
+mkdirp.sync(dir, mode)
+----------------------
+
+Synchronously create a new directory and any necessary subdirectories at `dir`
+with octal permission string `mode`.
+
+If `mode` isn't specified, it defaults to `0777 & (~process.umask())`.
+
+install
+=======
+
+With [npm](http://npmjs.org) do:
+
+ npm install mkdirp
+
+license
+=======
+
+MIT/X11
module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
function mkdirP (p, mode, f) {
+ if (typeof mode === 'function' || mode === undefined) {
+ f = mode;
+ mode = 0777 & (~process.umask());
+ }
+
+ // secret passalong argument.
+ var made = arguments[3] || null;
+
var cb = f || function () {};
if (typeof mode === 'string') mode = parseInt(mode, 8);
p = path.resolve(p);
fs.mkdir(p, mode, function (er) {
- if (!er) return cb();
+ if (!er) {
+ made = made || p;
+ return cb(null, made);
+ }
switch (er.code) {
case 'ENOENT':
- mkdirP(path.dirname(p), mode, function (er) {
- if (er) cb(er);
- else mkdirP(p, mode, cb);
+ mkdirP(path.dirname(p), mode, function (er, made) {
+ if (er) cb(er, made);
+ else mkdirP(p, mode, cb, made);
});
break;
fs.stat(p, function (er2, stat) {
// if the stat fails, then that's super weird.
// let the original EEXIST be the failure reason.
- if (er2 || !stat.isDirectory()) cb(er)
- else if ((stat.mode & 0777) !== mode) fs.chmod(p, mode, cb);
- else cb();
+ if (er2 || !stat.isDirectory()) cb(er, made)
+ else cb(null, made);
});
break;
default:
- cb(er);
+ cb(er, made);
break;
}
});
}
+
+mkdirP.sync = function sync (p, mode) {
+ if (mode === undefined) {
+ mode = 0777 & (~process.umask());
+ }
+
+ // secret passalong argument
+ var made = arguments[2] || null;
+
+ if (typeof mode === 'string') mode = parseInt(mode, 8);
+ p = path.resolve(p);
+
+ try {
+ fs.mkdirSync(p, mode);
+ made = made || p;
+ }
+ catch (err0) {
+ switch (err0.code) {
+ case 'ENOENT' :
+ made = sync(path.dirname(p), mode, made);
+ sync(p, mode, made);
+ break;
+
+ case 'EEXIST' :
+ var stat;
+ try {
+ stat = fs.statSync(p);
+ }
+ catch (err1) {
+ throw err0;
+ }
+ if (!stat.isDirectory()) throw err0;
+ break;
+ default :
+ throw err0
+ break;
+ }
+ }
+
+ return made;
+};
{
- "name" : "mkdirp",
- "description" : "Recursively mkdir, like `mkdir -p`",
- "version" : "0.1.0",
- "author" : "James Halliday <mail@substack.net> (http://substack.net)",
- "main" : "./index",
- "keywords" : [
- "mkdir",
- "directory"
- ],
- "repository" : {
- "type" : "git",
- "url" : "http://github.com/substack/node-mkdirp.git"
- },
- "scripts" : {
- "test" : "tap test/*.js"
- },
- "devDependencies" : {
- "tap" : "0.0.x"
- },
- "license" : "MIT/X11",
- "engines": { "node": "*" }
+ "name": "mkdirp",
+ "description": "Recursively mkdir, like `mkdir -p`",
+ "version": "0.3.0",
+ "author": {
+ "name": "James Halliday",
+ "email": "mail@substack.net",
+ "url": "http://substack.net"
+ },
+ "main": "./index",
+ "keywords": [
+ "mkdir",
+ "directory"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/substack/node-mkdirp.git"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "devDependencies": {
+ "tap": "0.2"
+ },
+ "license": "MIT/X11",
+ "engines": {
+ "node": "*"
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "mkdirp@0.3.0",
+ "dependencies": {},
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.13",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "a3cc6816e78b84f570caf9d95cb7368dc5d0bab8"
+ },
+ "_from": "../mkdirp"
}
, tty = require("tty")
, StringDecoder = require("string_decoder").StringDecoder
+function raw (mode) {
+ try {
+ process.stdin.setRawMode(mode)
+ } catch (e) {
+ tty.setRawMode(mode)
+ }
+}
+
function read (opts, cb) {
if (!cb) cb = opts, opts = {}
cb = (function (cb) {
var called = false
var t = setTimeout(function () {
- tty.setRawMode(false)
+ raw(false)
process.stdout.write("\n")
if (def) done(null, def)
else done(new Error("timeout"))
, val = ""
, decoder = new StringDecoder
- tty.setRawMode(true)
+ raw(true)
stdin.resume()
stdin.on("error", cb)
stdin.on("data", function D (c) {
case "\u0004": // EOF
case delim:
- tty.setRawMode(false)
+ raw(false)
stdin.removeListener("data", D)
stdin.removeListener("error", cb)
val = val.trim() || def
return cb(null, val)
case "\u0003": case "\0": // ^C or other signal abort
- tty.setRawMode(false)
+ raw(false)
stdin.removeListener("data", D)
stdin.removeListener("error", cb)
stdin.pause()
{
"name": "read",
- "version": "0.0.1",
+ "version": "0.0.2",
"main": "lib/read.js",
"dependencies": {},
"devDependencies": {},
"engines": {
"node": ">=0.6"
},
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
"description": "read(1) for node programs",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/read.git"
- }
+ },
+ "license": "BSD",
+ "_id": "read@0.0.2",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.15",
+ "_nodeVersion": "v0.7.7",
+ "_defaultsLoaded": true,
+ "_from": "read@0"
}
You can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types, in this case `application/json`, and use the proper content-type in the PUT request if one is not already provided in the headers.
```javascript
-fs.readStream('file.json').pipe(request.put('http://mysite.com/obj.json'))
+fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'))
```
Request can also pipe to itself. When doing so the content-type and content-length will be preserved in the PUT headers.
The first argument can be either a url or an options object. The only required option is uri, all others are optional.
* `uri` || `url` - fully qualified uri or a parsed url object from url.parse()
+* `qs` - object containing querystring values to be appended to the uri
* `method` - http method, defaults to GET
* `headers` - http headers, defaults to {}
* `body` - entity body for POST and PUT requests. Must be buffer or string.
* `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header.
* `multipart` - (experimental) array of objects which contains their own headers and `body` attribute. Sends `multipart/related` request. See example below.
* `followRedirect` - follow HTTP 3xx responses as redirects. defaults to true.
+* `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects. defaults to false.
* `maxRedirects` - the maximum number of redirects to follow, defaults to 10.
* `onResponse` - If true the callback will be fired on the "response" event instead of "end". If a function it will be called on "response" and not effect the regular semantics of the main callback on "end".
* `encoding` - Encoding to be used on `setEncoding` of response data. If set to `null`, the body is returned as a Buffer.
module.exports = ForeverAgent
+ForeverAgent.SSL = ForeverAgentSSL
var util = require('util')
, Agent = require('http').Agent
, net = require('net')
+ , tls = require('tls')
+ , AgentSSL = require('https').Agent
function ForeverAgent(options) {
var self = this
socket.destroy();
}
})
- self.createConnection = net.createConnection
+
}
util.inherits(ForeverAgent, Agent)
ForeverAgent.defaultMinSockets = 5
+
+ForeverAgent.prototype.createConnection = net.createConnection
ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest
ForeverAgent.prototype.addRequest = function(req, host, port) {
var name = host + ':' + port
this.createSocket(name, host, port).emit('free');
}
}
+
+function ForeverAgentSSL (options) {
+ ForeverAgent.call(this, options)
+}
+util.inherits(ForeverAgentSSL, ForeverAgent)
+
+ForeverAgentSSL.prototype.createConnection = createConnectionSSL
+ForeverAgentSSL.prototype.addRequestNoreuse = AgentSSL.prototype.addRequest
+
+function createConnectionSSL (port, host, options) {
+ options.port = port
+ options.host = host
+ return tls.connect(options)
+}
-// Copyright 2010-2011 Mikeal Rogers
+// Copyright 2010-2012 Mikeal Rogers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
, Cookie = require('./vendor/cookie')
, CookieJar = require('./vendor/cookie/jar')
, cookieJar = new CookieJar
+ , tunnel = require('./tunnel')
;
if (process.logging) {
function copy (obj) {
var o = {}
- for (var i in obj) o[i] = obj[i]
+ Object.keys(obj).forEach(function (i) {
+ o[i] = obj[i]
+ })
return o
}
if (typeof options === 'string') {
options = {uri:options}
}
-
+
+ var reserved = Object.keys(Request.prototype)
for (var i in options) {
- this[i] = options[i]
+ if (reserved.indexOf(i) === -1) {
+ this[i] = options[i]
+ } else {
+ if (typeof options[i] === 'function') {
+ delete options[i]
+ }
+ }
}
- if (!this.pool) this.pool = globalPool
- this.dests = []
- this.__isRequestRequest = true
+ options = copy(options)
+
+ this.init(options)
}
util.inherits(Request, stream.Stream)
-Request.prototype.getAgent = function (host, port) {
- if (!this.pool[host+':'+port]) {
- this.pool[host+':'+port] = new this.httpModule.Agent({host:host, port:port})
- }
- return this.pool[host+':'+port]
-}
-Request.prototype.request = function () {
+Request.prototype.init = function (options) {
var self = this
-
+
+ if (!options) options = {}
+
+ if (!self.pool) self.pool = globalPool
+ self.dests = []
+ self.__isRequestRequest = true
+
// Protect against double callback
if (!self._callback && self.callback) {
self._callback = self.callback
}
if (self.proxy) {
if (typeof self.proxy == 'string') self.proxy = url.parse(self.proxy)
+
+ // do the HTTP CONNECT dance using koichik/node-tunnel
+ if (http.globalAgent && self.uri.protocol === "https:") {
+ var tunnelFn = self.proxy.protocol === "http:"
+ ? tunnel.httpsOverHttp : tunnel.httpsOverHttps
+
+ var tunnelOptions = { proxy: { host: self.proxy.hostname
+ , port: +self.proxy.port
+ , proxyAuth: self.proxy.auth }
+ , ca: this.ca }
+
+ self.agent = tunnelFn(tunnelOptions)
+ self.tunnel = true
+ }
}
self._redirectsFollowed = self._redirectsFollowed || 0
self.maxRedirects = (self.maxRedirects !== undefined) ? self.maxRedirects : 10
self.followRedirect = (self.followRedirect !== undefined) ? self.followRedirect : true
- if (self.followRedirect)
+ self.followAllRedirects = (self.followAllRedirects !== undefined) ? self.followAllRedirects : false;
+ if (self.followRedirect || self.followAllRedirects)
self.redirects = self.redirects || []
self.headers = self.headers ? copy(self.headers) : {}
- var setHost = false
+ self.setHost = false
if (!self.headers.host) {
self.headers.host = self.uri.hostname
if (self.uri.port) {
!(self.uri.port === 443 && self.uri.protocol === 'https:') )
self.headers.host += (':'+self.uri.port)
}
- setHost = true
- }
-
- if (self.jar === false) {
- // disable cookies
- var cookies = false;
- self._disableCookies = true;
- } else if (self.jar) {
- // fetch cookie from the user defined cookie jar
- var cookies = self.jar.get({ url: self.uri.href })
- } else {
- // fetch cookie from the global cookie jar
- var cookies = cookieJar.get({ url: self.uri.href })
- }
- if (cookies) {
- var cookieString = cookies.map(function (c) {
- return c.name + "=" + c.value;
- }).join("; ");
-
- self.headers.Cookie = cookieString;
+ self.setHost = true
}
+
+ self.jar(self._jar || options.jar)
if (!self.uri.pathname) {self.uri.pathname = '/'}
if (!self.uri.port) {
else if (self.uri.protocol == 'https:') {self.uri.port = 443}
}
- if (self.proxy) {
+ if (self.proxy && !self.tunnel) {
self.port = self.proxy.port
self.host = self.proxy.hostname
} else {
delete self.callback
}
- var clientErrorHandler = function (error) {
- if (setHost) delete self.headers.host
- if (self.req._reusedSocket && error.code === 'ECONNRESET') {
- self.agent = {addRequest: ForeverAgent.prototype.addRequestNoreuse.bind(self.agent)}
+ self.clientErrorHandler = function (error) {
+ if (self._aborted) return
+
+ if (self.setHost) delete self.headers.host
+ if (self.req._reusedSocket && error.code === 'ECONNRESET'
+ && self.agent.addRequestNoreuse) {
+ self.agent = { addRequest: self.agent.addRequestNoreuse.bind(self.agent) }
self.start()
self.req.end()
return
}
- if (self.timeout && self.timeoutTimer) clearTimeout(self.timeoutTimer)
+ if (self.timeout && self.timeoutTimer) {
+ clearTimeout(self.timeoutTimer);
+ self.timeoutTimer = null;
+ }
self.emit('error', error)
}
if (self.onResponse) self.on('error', function (e) {self.onResponse(e)})
if (self.callback) self.on('error', function (e) {self.callback(e)})
- if (self.form) {
- self.headers['content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'
- self.body = qs.stringify(self.form).toString('utf8')
- }
-
- if (self.oauth) {
- var form
- if (self.headers['content-type'] &&
- self.headers['content-type'].slice(0, 'application/x-www-form-urlencoded'.length) ===
- 'application/x-www-form-urlencoded'
- ) {
- form = qs.parse(self.body)
- }
- if (self.uri.query) {
- form = qs.parse(self.uri.query)
- }
- if (!form) form = {}
- var oa = {}
- for (var i in form) oa[i] = form[i]
- for (var i in self.oauth) oa['oauth_'+i] = self.oauth[i]
- if (!oa.oauth_version) oa.oauth_version = '1.0'
- if (!oa.oauth_timestamp) oa.oauth_timestamp = Math.floor( (new Date()).getTime() / 1000 ).toString()
- if (!oa.oauth_nonce) oa.oauth_nonce = uuid().replace(/-/g, '')
-
- oa.oauth_signature_method = 'HMAC-SHA1'
-
- var consumer_secret = oa.oauth_consumer_secret
- delete oa.oauth_consumer_secret
- var token_secret = oa.oauth_token_secret
- delete oa.oauth_token_secret
-
- var baseurl = self.uri.protocol + '//' + self.uri.host + self.uri.pathname
- var signature = oauth.hmacsign(self.method, baseurl, oa, consumer_secret, token_secret)
-
- // oa.oauth_signature = signature
- for (var i in form) {
- if ( i.slice(0, 'oauth_') in self.oauth) {
- // skip
- } else {
- delete oa['oauth_'+i]
- }
- }
- self.headers.authorization =
- 'OAuth '+Object.keys(oa).sort().map(function (i) {return i+'="'+oauth.rfc3986(oa[i])+'"'}).join(',')
- self.headers.authorization += ',oauth_signature="'+oauth.rfc3986(signature)+'"'
+ if (options.form) {
+ self.form(options.form)
+ }
+
+ if (options.oauth) {
+ self.oauth(options.oauth)
}
if (self.uri.auth && !self.headers.authorization) {
self.headers.authorization = "Basic " + toBase64(self.uri.auth.split(':').map(function(item){ return qs.unescape(item)}).join(':'))
}
- if (self.proxy && self.proxy.auth && !self.headers['proxy-authorization']) {
+ if (self.proxy && self.proxy.auth && !self.headers['proxy-authorization'] && !self.tunnel) {
self.headers['proxy-authorization'] = "Basic " + toBase64(self.proxy.auth.split(':').map(function(item){ return qs.unescape(item)}).join(':'))
}
+ if (options.qs) self.qs(options.qs)
+
if (self.uri.path) {
self.path = self.uri.path
} else {
if (self.path.length === 0) self.path = '/'
- if (self.proxy) self.path = (self.uri.protocol + '//' + self.uri.host + self.path)
-
- if (self.json) {
- self.headers['content-type'] = 'application/json'
- if (typeof self.json === 'boolean') {
- if (typeof self.body === 'object') self.body = JSON.stringify(self.body)
- } else {
- self.body = JSON.stringify(self.json)
- }
-
- } else if (self.multipart) {
- self.body = []
-
- if (!self.headers['content-type']) {
- self.headers['content-type'] = 'multipart/related;boundary="frontier"';
- } else {
- self.headers['content-type'] = self.headers['content-type'].split(';')[0] + ';boundary="frontier"';
- }
-
- if (!self.multipart.forEach) throw new Error('Argument error, options.multipart.')
+ if (self.proxy && !self.tunnel) self.path = (self.uri.protocol + '//' + self.uri.host + self.path)
- self.multipart.forEach(function (part) {
- var body = part.body
- if(!body) throw Error('Body attribute missing in multipart.')
- delete part.body
- var preamble = '--frontier\r\n'
- Object.keys(part).forEach(function(key){
- preamble += key + ': ' + part[key] + '\r\n'
- })
- preamble += '\r\n'
- self.body.push(new Buffer(preamble))
- self.body.push(new Buffer(body))
- self.body.push(new Buffer('\r\n'))
- })
- self.body.push(new Buffer('--frontier--'))
+ if (options.json) {
+ self.json(options.json)
+ } else if (options.multipart) {
+ self.multipart(options.multipart)
}
if (self.body) {
}
}
- var protocol = self.proxy ? self.proxy.protocol : self.uri.protocol
+ var protocol = self.proxy && !self.tunnel ? self.proxy.protocol : self.uri.protocol
, defaultModules = {'http:':http, 'https:':https}
, httpModules = self.httpModules || {}
;
if (!self.httpModule) throw new Error("Invalid protocol")
+ if (options.ca) self.ca = options.ca
+
+ if (!self.agent) {
+ if (options.agentOptions) self.agentOptions = options.agentOptions
+
+ if (options.agentClass) {
+ self.agentClass = options.agentClass
+ } else if (options.forever) {
+ self.agentClass = protocol === 'http:' ? ForeverAgent : ForeverAgent.SSL
+ } else {
+ self.agentClass = self.httpModule.Agent
+ }
+ }
+
if (self.pool === false) {
self.agent = false
} else {
+ self.agent = self.agent || self.getAgent()
if (self.maxSockets) {
// Don't use our pooling if node has the refactored client
- self.agent = self.agent || self.httpModule.globalAgent || self.getAgent(self.host, self.port)
self.agent.maxSockets = self.maxSockets
}
if (self.pool.maxSockets) {
// Don't use our pooling if node has the refactored client
- self.agent = self.agent || self.httpModule.globalAgent || self.getAgent(self.host, self.port)
self.agent.maxSockets = self.pool.maxSockets
}
}
- self.start = function () {
- self._started = true
- self.method = self.method || 'GET'
- self.href = self.uri.href
- if (log) log('%method %href', self)
- self.req = self.httpModule.request(self, function (response) {
- self.response = response
- response.request = self
-
- if (self.httpModule === https &&
- self.strictSSL &&
- !response.client.authorized) {
- var sslErr = response.client.authorizationError
- self.emit('error', new Error('SSL Error: '+ sslErr))
- return
- }
-
- if (setHost) delete self.headers.host
- if (self.timeout && self.timeoutTimer) clearTimeout(self.timeoutTimer)
-
- if (response.headers['set-cookie'] && (!self._disableCookies)) {
- response.headers['set-cookie'].forEach(function(cookie) {
- if (self.jar) self.jar.add(new Cookie(cookie))
- else cookieJar.add(new Cookie(cookie))
- })
- }
-
- if (response.statusCode >= 300 &&
- response.statusCode < 400 &&
- self.followRedirect &&
- self.method !== 'PUT' &&
- self.method !== 'POST' &&
- response.headers.location) {
- if (self._redirectsFollowed >= self.maxRedirects) {
- self.emit('error', new Error("Exceeded maxRedirects. Probably stuck in a redirect loop."))
- return
- }
- self._redirectsFollowed += 1
-
- if (!isUrl.test(response.headers.location)) {
- response.headers.location = url.resolve(self.uri.href, response.headers.location)
- }
- self.uri = response.headers.location
- self.redirects.push(
- { statusCode : response.statusCode
- , redirectUri: response.headers.location
- }
- )
- delete self.req
- delete self.agent
- delete self._started
- if (self.headers) {
- delete self.headers.host
- }
- if (log) log('Redirect to %uri', self)
- request(self, self.callback)
- return // Ignore the rest of the response
- } else {
- self._redirectsFollowed = self._redirectsFollowed || 0
- // Be a good stream and emit end when the response is finished.
- // Hack to emit end on close because of a core bug that never fires end
- response.on('close', function () {
- if (!self._ended) self.response.emit('end')
- })
-
- if (self.encoding) {
- if (self.dests.length !== 0) {
- console.error("Ingoring encoding parameter as this stream is being piped to another stream which makes the encoding option invalid.")
- } else {
- response.setEncoding(self.encoding)
- }
- }
-
- self.pipeDest = function (dest) {
- if (dest.headers) {
- dest.headers['content-type'] = response.headers['content-type']
- if (response.headers['content-length']) {
- dest.headers['content-length'] = response.headers['content-length']
- }
- }
- if (dest.setHeader) {
- for (var i in response.headers) {
- dest.setHeader(i, response.headers[i])
- }
- dest.statusCode = response.statusCode
- }
- if (self.pipefilter) self.pipefilter(response, dest)
- }
-
- self.dests.forEach(function (dest) {
- self.pipeDest(dest)
- })
-
- response.on("data", function (chunk) {
- self._destdata = true
- self.emit("data", chunk)
- })
- response.on("end", function (chunk) {
- self._ended = true
- self.emit("end", chunk)
- })
- response.on("close", function () {self.emit("close")})
-
- self.emit('response', response)
-
- if (self.onResponse) {
- self.onResponse(null, response)
- }
- if (self.callback) {
- var buffer = []
- var bodyLen = 0
- self.on("data", function (chunk) {
- buffer.push(chunk)
- bodyLen += chunk.length
- })
- self.on("end", function () {
- if (buffer.length && Buffer.isBuffer(buffer[0])) {
- var body = new Buffer(bodyLen)
- var i = 0
- buffer.forEach(function (chunk) {
- chunk.copy(body, i, 0, chunk.length)
- i += chunk.length
- })
- if (self.encoding === null) {
- response.body = body
- } else {
- response.body = body.toString()
- }
- } else if (buffer.length) {
- response.body = buffer.join('')
- }
-
- if (self.json) {
- try {
- response.body = JSON.parse(response.body)
- } catch (e) {}
- }
-
- self.callback(null, response, response.body)
- })
- }
- }
- })
-
- if (self.timeout && !self.timeoutTimer) {
- self.timeoutTimer = setTimeout(function() {
- self.req.abort()
- var e = new Error("ETIMEDOUT")
- e.code = "ETIMEDOUT"
- self.emit("error", e)
- }, self.timeout)
- }
-
- self.req.on('error', clientErrorHandler)
- }
-
self.once('pipe', function (src) {
if (self.ntick) throw new Error("You cannot pipe to this stream after the first nextTick() after creation of the request stream.")
self.src = src
})
process.nextTick(function () {
+ if (self._aborted) return
+
if (self.body) {
if (Array.isArray(self.body)) {
self.body.forEach(function(part) {
self.ntick = true
})
}
-Request.prototype.pipe = function (dest) {
+
+// Must call this when following a redirect from https to http or vice versa
+// Attempts to keep everything as identical as possible, but update the
+// httpModule, Tunneling agent, and/or Forever Agent in use.
+Request.prototype._updateProtocol = function () {
+ var self = this
+ var protocol = self.uri.protocol
+
+ if (protocol === 'https:') {
+ // previously was doing http, now doing https
+ // if it's https, then we might need to tunnel now.
+ if (self.proxy) {
+ self.tunnel = true
+ var tunnelFn = self.proxy.protocol === 'http:'
+ ? tunnel.httpsOverHttp : tunnel.httpsOverHttps
+ var tunnelOptions = { proxy: { host: self.proxy.hostname
+ , post: +self.proxy.port
+ , proxyAuth: self.proxy.auth }
+ , ca: self.ca }
+ self.agent = tunnelFn(tunnelOptions)
+ return
+ }
+
+ self.httpModule = https
+ switch (self.agentClass) {
+ case ForeverAgent:
+ self.agentClass = ForeverAgent.SSL
+ break
+ case http.Agent:
+ self.agentClass = https.Agent
+ break
+ default:
+ // nothing we can do. Just hope for the best.
+ return
+ }
+
+ // if there's an agent, we need to get a new one.
+ if (self.agent) self.agent = self.getAgent()
+
+ } else {
+ if (log) log('previously https, now http')
+ // previously was doing https, now doing http
+ // stop any tunneling.
+ if (self.tunnel) self.tunnel = false
+ self.httpModule = http
+ switch (self.agentClass) {
+ case ForeverAgent.SSL:
+ self.agentClass = ForeverAgent
+ break
+ case https.Agent:
+ self.agentClass = http.Agent
+ break
+ default:
+ // nothing we can do. just hope for the best
+ return
+ }
+
+ // if there's an agent, then get a new one.
+ if (self.agent) {
+ self.agent = null
+ self.agent = self.getAgent()
+ }
+ }
+}
+
+Request.prototype.getAgent = function () {
+ var Agent = this.agentClass
+ var options = {}
+ if (this.agentOptions) {
+ for (var i in this.agentOptions) {
+ options[i] = this.agentOptions[i]
+ }
+ }
+ if (this.ca) options.ca = this.ca
+
+ var poolKey = ''
+
+ // different types of agents are in different pools
+ if (Agent !== this.httpModule.Agent) {
+ poolKey += Agent.name
+ }
+
+ if (!this.httpModule.globalAgent) {
+ // node 0.4.x
+ options.host = this.host
+ options.port = this.port
+ if (poolKey) poolKey += ':'
+ poolKey += this.host + ':' + this.port
+ }
+
+ // ca option is only relevant if proxy or destination are https
+ var proxy = this.proxy
+ if (typeof proxy === 'string') proxy = url.parse(proxy)
+ var caRelevant = (proxy && proxy.protocol === 'https:') || this.uri.protocol === 'https:'
+ if (options.ca && caRelevant) {
+ if (poolKey) poolKey += ':'
+ poolKey += options.ca
+ }
+
+ if (!poolKey && Agent === this.httpModule.Agent && this.httpModule.globalAgent) {
+ // not doing anything special. Use the globalAgent
+ return this.httpModule.globalAgent
+ }
+
+ // we're using a stored agent. Make sure it's protocol-specific
+ poolKey = this.uri.protocol + poolKey
+
+ // already generated an agent for this setting
+ if (this.pool[poolKey]) return this.pool[poolKey]
+
+ return this.pool[poolKey] = new Agent(options)
+}
+
+Request.prototype.start = function () {
+ var self = this
+
+ if (self._aborted) return
+
+ self._started = true
+ self.method = self.method || 'GET'
+ self.href = self.uri.href
+ if (log) log('%method %href', self)
+ self.req = self.httpModule.request(self, function (response) {
+ if (self._aborted) return
+ if (self._paused) response.pause()
+
+ self.response = response
+ response.request = self
+
+ if (self.httpModule === https &&
+ self.strictSSL &&
+ !response.client.authorized) {
+ var sslErr = response.client.authorizationError
+ self.emit('error', new Error('SSL Error: '+ sslErr))
+ return
+ }
+
+ if (self.setHost) delete self.headers.host
+ if (self.timeout && self.timeoutTimer) {
+ clearTimeout(self.timeoutTimer);
+ self.timeoutTimer = null;
+ }
+
+ if (response.headers['set-cookie'] && (!self._disableCookies)) {
+ response.headers['set-cookie'].forEach(function(cookie) {
+ if (self._jar) self._jar.add(new Cookie(cookie))
+ else cookieJar.add(new Cookie(cookie))
+ })
+ }
+
+ if (response.statusCode >= 300 && response.statusCode < 400 &&
+ (self.followAllRedirects ||
+ (self.followRedirect && (self.method !== 'PUT' && self.method !== 'POST' && self.method !== 'DELETE'))) &&
+ response.headers.location) {
+ if (self._redirectsFollowed >= self.maxRedirects) {
+ self.emit('error', new Error("Exceeded maxRedirects. Probably stuck in a redirect loop."))
+ return
+ }
+ self._redirectsFollowed += 1
+
+ if (!isUrl.test(response.headers.location)) {
+ response.headers.location = url.resolve(self.uri.href, response.headers.location)
+ }
+
+ var uriPrev = self.uri
+ self.uri = url.parse(response.headers.location)
+
+ // handle the case where we change protocol from https to http or vice versa
+ if (self.uri.protocol !== uriPrev.protocol) {
+ self._updateProtocol()
+ }
+
+ self.redirects.push(
+ { statusCode : response.statusCode
+ , redirectUri: response.headers.location
+ }
+ )
+ self.method = 'GET'; // Force all redirects to use GET
+ delete self.req
+ delete self.agent
+ delete self._started
+ delete self.body
+ if (self.headers) {
+ delete self.headers.host
+ }
+ if (log) log('Redirect to %uri', self)
+ self.init()
+ return // Ignore the rest of the response
+ } else {
+ self._redirectsFollowed = self._redirectsFollowed || 0
+ // Be a good stream and emit end when the response is finished.
+ // Hack to emit end on close because of a core bug that never fires end
+ response.on('close', function () {
+ if (!self._ended) self.response.emit('end')
+ })
+
+ if (self.encoding) {
+ if (self.dests.length !== 0) {
+ console.error("Ingoring encoding parameter as this stream is being piped to another stream which makes the encoding option invalid.")
+ } else {
+ response.setEncoding(self.encoding)
+ }
+ }
+
+ self.dests.forEach(function (dest) {
+ self.pipeDest(dest)
+ })
+
+ response.on("data", function (chunk) {
+ self._destdata = true
+ self.emit("data", chunk)
+ })
+ response.on("end", function (chunk) {
+ self._ended = true
+ self.emit("end", chunk)
+ })
+ response.on("close", function () {self.emit("close")})
+
+ self.emit('response', response)
+
+ if (self.onResponse) {
+ self.onResponse(null, response)
+ }
+ if (self.callback) {
+ var buffer = []
+ var bodyLen = 0
+ self.on("data", function (chunk) {
+ buffer.push(chunk)
+ bodyLen += chunk.length
+ })
+ self.on("end", function () {
+ if (self._aborted) return
+
+ if (buffer.length && Buffer.isBuffer(buffer[0])) {
+ var body = new Buffer(bodyLen)
+ var i = 0
+ buffer.forEach(function (chunk) {
+ chunk.copy(body, i, 0, chunk.length)
+ i += chunk.length
+ })
+ if (self.encoding === null) {
+ response.body = body
+ } else {
+ response.body = body.toString()
+ }
+ } else if (buffer.length) {
+ response.body = buffer.join('')
+ }
+
+ if (self._json) {
+ try {
+ response.body = JSON.parse(response.body)
+ } catch (e) {}
+ }
+
+ self.callback(null, response, response.body)
+ })
+ }
+ }
+ })
+
+ if (self.timeout && !self.timeoutTimer) {
+ self.timeoutTimer = setTimeout(function() {
+ self.req.abort()
+ var e = new Error("ETIMEDOUT")
+ e.code = "ETIMEDOUT"
+ self.emit("error", e)
+ }, self.timeout)
+
+ // Set additional timeout on socket - in case if remote
+ // server freeze after sending headers
+ if (self.req.setTimeout) { // only works on node 0.6+
+ self.req.setTimeout(self.timeout, function(){
+ if (self.req) {
+ self.req.abort()
+ var e = new Error("ESOCKETTIMEDOUT")
+ e.code = "ESOCKETTIMEDOUT"
+ self.emit("error", e)
+ }
+ })
+ }
+ }
+
+ self.req.on('error', self.clientErrorHandler)
+
+ self.emit('request', self.req)
+}
+
+Request.prototype.abort = function() {
+ this._aborted = true;
+
+ if (this.req) {
+ this.req.abort()
+ }
+ else if (this.response) {
+ this.response.abort()
+ }
+
+ this.emit("abort")
+}
+
+Request.prototype.pipeDest = function (dest) {
+ var response = this.response
+ // Called after the response is received
+ if (dest.headers) {
+ dest.headers['content-type'] = response.headers['content-type']
+ if (response.headers['content-length']) {
+ dest.headers['content-length'] = response.headers['content-length']
+ }
+ }
+ if (dest.setHeader) {
+ for (var i in response.headers) {
+ dest.setHeader(i, response.headers[i])
+ }
+ dest.statusCode = response.statusCode
+ }
+ if (this.pipefilter) this.pipefilter(response, dest)
+}
+
+// Composable API
+Request.prototype.setHeader = function (name, value, clobber) {
+ if (clobber === undefined) clobber = true
+ if (clobber || !this.headers.hasOwnProperty(name)) this.headers[name] = value
+ else this.headers[name] += ',' + value
+ return this
+}
+Request.prototype.setHeaders = function (headers) {
+ for (i in headers) {this.setHeader(i, headers[i])}
+ return this
+}
+Request.prototype.qs = function (q, clobber) {
+ var base
+ if (!clobber && this.uri.query) base = qs.parse(this.uri.query)
+ else base = {}
+
+ for (var i in q) {
+ base[i] = q[i]
+ }
+
+ this.uri = url.parse(this.uri.href.split('?')[0] + '?' + qs.stringify(base))
+ this.url = this.uri
+
+ return this
+}
+Request.prototype.form = function (form) {
+ this.headers['content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'
+ this.body = qs.stringify(form).toString('utf8')
+ return this
+}
+Request.prototype.multipart = function (multipart) {
+ var self = this
+ self.body = []
+
+ if (!self.headers['content-type']) {
+ self.headers['content-type'] = 'multipart/related;boundary="frontier"';
+ } else {
+ self.headers['content-type'] = self.headers['content-type'].split(';')[0] + ';boundary="frontier"';
+ }
+
+ if (!multipart.forEach) throw new Error('Argument error, options.multipart.')
+
+ multipart.forEach(function (part) {
+ var body = part.body
+ if(!body) throw Error('Body attribute missing in multipart.')
+ delete part.body
+ var preamble = '--frontier\r\n'
+ Object.keys(part).forEach(function(key){
+ preamble += key + ': ' + part[key] + '\r\n'
+ })
+ preamble += '\r\n'
+ self.body.push(new Buffer(preamble))
+ self.body.push(new Buffer(body))
+ self.body.push(new Buffer('\r\n'))
+ })
+ self.body.push(new Buffer('--frontier--'))
+ return self
+}
+Request.prototype.json = function (val) {
+ this.setHeader('content-type', 'application/json')
+ this.setHeader('accept', 'application/json')
+ this._json = true
+ if (typeof val === 'boolean') {
+ if (typeof this.body === 'object') this.body = JSON.stringify(this.body)
+ } else {
+ this.body = JSON.stringify(val)
+ }
+ return this
+}
+Request.prototype.oauth = function (_oauth) {
+ var form
+ if (this.headers['content-type'] &&
+ this.headers['content-type'].slice(0, 'application/x-www-form-urlencoded'.length) ===
+ 'application/x-www-form-urlencoded'
+ ) {
+ form = qs.parse(this.body)
+ }
+ if (this.uri.query) {
+ form = qs.parse(this.uri.query)
+ }
+ if (!form) form = {}
+ var oa = {}
+ for (var i in form) oa[i] = form[i]
+ for (var i in _oauth) oa['oauth_'+i] = _oauth[i]
+ if (!oa.oauth_version) oa.oauth_version = '1.0'
+ if (!oa.oauth_timestamp) oa.oauth_timestamp = Math.floor( (new Date()).getTime() / 1000 ).toString()
+ if (!oa.oauth_nonce) oa.oauth_nonce = uuid().replace(/-/g, '')
+
+ oa.oauth_signature_method = 'HMAC-SHA1'
+
+ var consumer_secret = oa.oauth_consumer_secret
+ delete oa.oauth_consumer_secret
+ var token_secret = oa.oauth_token_secret
+ delete oa.oauth_token_secret
+
+ var baseurl = this.uri.protocol + '//' + this.uri.host + this.uri.pathname
+ var signature = oauth.hmacsign(this.method, baseurl, oa, consumer_secret, token_secret)
+
+ // oa.oauth_signature = signature
+ for (var i in form) {
+ if ( i.slice(0, 'oauth_') in _oauth) {
+ // skip
+ } else {
+ delete oa['oauth_'+i]
+ }
+ }
+ this.headers.authorization =
+ 'OAuth '+Object.keys(oa).sort().map(function (i) {return i+'="'+oauth.rfc3986(oa[i])+'"'}).join(',')
+ this.headers.authorization += ',oauth_signature="'+oauth.rfc3986(signature)+'"'
+ return this
+}
+Request.prototype.jar = function (jar) {
+ var cookies
+
+ if (this._redirectsFollowed === 0) {
+ this.originalCookieHeader = this.headers.cookie
+ }
+
+ if (jar === false) {
+ // disable cookies
+ cookies = false;
+ this._disableCookies = true;
+ } else if (jar) {
+ // fetch cookie from the user defined cookie jar
+ cookies = jar.get({ url: this.uri.href })
+ } else {
+ // fetch cookie from the global cookie jar
+ cookies = cookieJar.get({ url: this.uri.href })
+ }
+
+ if (cookies && cookies.length) {
+ var cookieString = cookies.map(function (c) {
+ return c.name + "=" + c.value
+ }).join("; ")
+
+ if (this.originalCookieHeader) {
+ // Don't overwrite existing Cookie header
+ this.headers.cookie = this.originalCookieHeader + '; ' + cookieString
+ } else {
+ this.headers.cookie = cookieString
+ }
+ }
+ this._jar = jar
+ return this
+}
+
+
+// Stream API
+Request.prototype.pipe = function (dest, opts) {
if (this.response) {
if (this._destdata) {
throw new Error("You cannot pipe after data has been emitted from the response.")
} else if (this._ended) {
throw new Error("You cannot pipe after the response has been ended.")
} else {
- stream.Stream.prototype.pipe.call(this, dest)
+ stream.Stream.prototype.pipe.call(this, dest, opts)
this.pipeDest(dest)
return dest
}
} else {
this.dests.push(dest)
- stream.Stream.prototype.pipe.call(this, dest)
+ stream.Stream.prototype.pipe.call(this, dest, opts)
return dest
}
}
Request.prototype.write = function () {
if (!this._started) this.start()
- if (!this.req) throw new Error("This request has been piped before http.request() was called.")
this.req.write.apply(this.req, arguments)
}
-Request.prototype.end = function () {
+Request.prototype.end = function (chunk) {
+ if (chunk) this.write(chunk)
if (!this._started) this.start()
- if (!this.req) throw new Error("This request has been piped before http.request() was called.")
- this.req.end.apply(this.req, arguments)
+ this.req.end()
}
Request.prototype.pause = function () {
- if (!this.response) throw new Error("This request has been piped before http.request() was called.")
- this.response.pause.apply(this.response, arguments)
+ if (!this.response) this._paused = true
+ else this.response.pause.apply(this.response, arguments)
}
Request.prototype.resume = function () {
- if (!this.response) throw new Error("This request has been piped before http.request() was called.")
- this.response.resume.apply(this.response, arguments)
+ if (!this.response) this._paused = false
+ else this.response.resume.apply(this.response, arguments)
+}
+Request.prototype.destroy = function () {
+ if (!this._ended) this.end()
}
-function request (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- if (callback) options.callback = callback
+// organize params for post, put, head, del
+function initParams(uri, options, callback) {
+ if ((typeof options === 'function') && !callback) callback = options;
+ if (typeof options === 'object') {
+ options.uri = uri;
+ } else if (typeof uri === 'string') {
+ options = {uri:uri};
+ } else {
+ options = uri;
+ uri = options.uri;
+ }
+ return { uri: uri, options: options, callback: callback };
+}
+
+function request (uri, options, callback) {
+ if (typeof uri === 'undefined') throw new Error('undefined is not a valid uri or options object.')
+ if ((typeof options === 'function') && !callback) callback = options;
+ if (typeof options === 'object') {
+ options.uri = uri;
+ } else if (typeof uri === 'string') {
+ options = {uri:uri};
+ } else {
+ options = uri;
+ }
+
+ if (callback) options.callback = callback;
var r = new Request(options)
- r.request()
return r
}
request.defaults = function (options) {
var def = function (method) {
- var d = function (opts, callback) {
- if (typeof opts === 'string') opts = {uri:opts}
+ var d = function (uri, opts, callback) {
+ var params = initParams(uri, opts, callback);
for (var i in options) {
- if (opts[i] === undefined) opts[i] = options[i]
+ if (params.options[i] === undefined) params.options[i] = options[i]
}
- return method(opts, callback)
+ return method(params.uri, params.options, params.callback)
}
return d
}
request.forever = function (agentOptions, optionsArg) {
var options = {}
- if (agentOptions) {
+ if (optionsArg) {
for (option in optionsArg) {
options[option] = optionsArg[option]
}
}
- options.agent = new ForeverAgent(agentOptions)
+ if (agentOptions) options.agentOptions = agentOptions
+ options.forever = true
return request.defaults(options)
}
request.get = request
-request.post = function (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- options.method = 'POST'
- return request(options, callback)
-}
-request.put = function (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- options.method = 'PUT'
- return request(options, callback)
-}
-request.head = function (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- options.method = 'HEAD'
- if (options.body || options.requestBodyStream || options.json || options.multipart) {
+request.post = function (uri, options, callback) {
+ var params = initParams(uri, options, callback);
+ params.options.method = 'POST';
+ return request(params.uri || null, params.options, params.callback)
+}
+request.put = function (uri, options, callback) {
+ var params = initParams(uri, options, callback);
+ params.options.method = 'PUT'
+ return request(params.uri || null, params.options, params.callback)
+}
+request.head = function (uri, options, callback) {
+ var params = initParams(uri, options, callback);
+ params.options.method = 'HEAD'
+ if (params.options.body ||
+ params.options.requestBodyStream ||
+ (params.options.json && typeof params.options.json !== 'boolean') ||
+ params.options.multipart) {
throw new Error("HTTP HEAD requests MUST NOT include a request body.")
}
- return request(options, callback)
+ return request(params.uri || null, params.options, params.callback)
}
-request.del = function (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- options.method = 'DELETE'
- return request(options, callback)
+request.del = function (uri, options, callback) {
+ var params = initParams(uri, options, callback);
+ params.options.method = 'DELETE'
+ return request(params.uri || null, params.options, params.callback)
}
request.jar = function () {
return new CookieJar
}
request.cookie = function (str) {
+ if (str && str.uri) str = str.uri
if (typeof str !== 'string') throw new Error("The cookie function only accepts STRING as param")
return new Cookie(str)
}
// from http://github.com/felixge/node-paperboy
exports.types = {
+ "3gp":"video/3gpp",
"aiff":"audio/x-aiff",
"arj":"application/x-arj-compressed",
"asf":"video/x-ms-asf",
"lzh":"application/octet-stream",
"m":"text/plain",
"m3u":"audio/x-mpegurl",
+ "m4v":"video/mp4",
"man":"application/x-troff-man",
"me":"application/x-troff-me",
"midi":"audio/midi",
"mif":"application/x-mif",
"mime":"www/mime",
+ "mkv":" video/x-matrosk",
"movie":"video/x-sgi-movie",
- "mustache":"text/plain",
"mp4":"video/mp4",
+ "mp41":"video/mp4",
+ "mp42":"video/mp4",
"mpg":"video/mpeg",
"mpga":"audio/mpeg",
"ms":"application/x-troff-ms",
+ "mustache":"text/plain",
"nc":"application/x-netcdf",
"oda":"application/oda",
"ogm":"application/ogg",
"vrm":"x-world/x-vrml",
"wav":"audio/x-wav",
"wax":"audio/x-ms-wax",
+ "webm":"video/webm",
"wma":"audio/x-ms-wma",
"wmv":"video/x-ms-wmv",
"wmx":"video/x-ms-wmx",
"xpm":"image/x-xpixmap",
"xwd":"image/x-xwindowdump",
"xyz":"chemical/x-pdb",
- "zip":"application/zip",
+ "zip":"application/zip"
};
exports.lookup = function(ext, defaultType) {
function hmacsign (httpMethod, base_uri, params, consumer_secret, token_secret, body) {
// adapted from https://dev.twitter.com/docs/auth/oauth
var base =
- httpMethod + "&" +
+ (httpMethod || 'GET') + "&" +
encodeURIComponent( base_uri ) + "&" +
Object.keys(params).sort().map(function (i) {
// big WTF here with the escape + encoding but it's what twitter wants
-{ "name" : "request"
-, "description" : "Simplified HTTP request client."
-, "tags" : ["http", "simple", "util", "utility"]
-, "version" : "2.9.3"
-, "author" : "Mikeal Rogers <mikeal.rogers@gmail.com>"
-, "repository" :
- { "type" : "git"
- , "url" : "http://github.com/mikeal/request.git"
- }
-, "bugs" :
- { "url" : "http://github.com/mikeal/request/issues" }
-, "engines" : ["node >= 0.3.6"]
-, "main" : "./main"
-, "scripts": { "test": "bash tests/run.sh" }
+{
+ "name": "request",
+ "description": "Simplified HTTP request client.",
+ "tags": [
+ "http",
+ "simple",
+ "util",
+ "utility"
+ ],
+ "version": "2.9.153",
+ "author": {
+ "name": "Mikeal Rogers",
+ "email": "mikeal.rogers@gmail.com"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/mikeal/request.git"
+ },
+ "bugs": {
+ "url": "http://github.com/mikeal/request/issues"
+ },
+ "engines": [
+ "node >= 0.3.6"
+ ],
+ "main": "./main",
+ "scripts": {
+ "test": "node tests/run.js"
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "request@2.9.153",
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.8",
+ "_nodeVersion": "v0.6.12",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "6f07c2ba3acfbe0cfe941f43647102740f05ff73"
+ },
+ "_from": "../request"
}
var Cookie = exports = module.exports = function Cookie(str, req) {
this.str = str;
- // First key is the name
- this.name = str.substr(0, str.indexOf('=')).trim();
-
// Map the key/val pairs
str.split(/ *; */).reduce(function(obj, pair){
var p = pair.indexOf('=');
- if(p > 0)
- obj[pair.substring(0, p).trim()] = pair.substring(p + 1).trim();
- else
- obj[pair.trim()] = true;
+ var key = p > 0 ? pair.substring(0, p).trim() : pair.trim();
+ var lowerCasedKey = key.toLowerCase();
+ var value = p > 0 ? pair.substring(p + 1).trim() : true;
+
+ if (!obj.name) {
+ // First key is the name
+ obj.name = key;
+ obj.value = value;
+ }
+ else if (lowerCasedKey === 'httponly') {
+ obj.httpOnly = value;
+ }
+ else {
+ obj[lowerCasedKey] = value;
+ }
return obj;
}, this);
- // Assign value
- this.value = this[this.name];
-
// Expires
this.expires = this.expires
? new Date(this.expires)
Wayne Larsen <wayne@larsen.st> (http://github.com/wvl)
ritch <skawful@gmail.com>
Marcel Laverdet
+Yosef Dinerstein <yosefd@microsoft.com>
## API
-`rimraf(f, [options,] callback)`
+`rimraf(f, callback)`
The callback will be called with an error if there is one. Certain
errors are handled for you:
* `EMFILE` - If too many file descriptors get opened, rimraf will
patiently wait until more become available.
-## Options
-
-The options object is optional. These fields are respected:
-
-* `maxBusyTries` - The number of times to retry a file or folder in the
- event of an `EBUSY` error. The default is 3.
-* `gently` - If provided a `gently` path, then rimraf will only delete
- files and folders that are beneath this path, and only delete symbolic
- links that point to a place within this path. (This is very important
- to npm's use-case, and shows rimraf's pedigree.)
-
## rimraf.sync
+++ /dev/null
-// fiber/future port originally written by Marcel Laverdet
-// https://gist.github.com/1131093
-// I updated it to bring to feature parity with cb version.
-// The bugs are probably mine, not Marcel's.
-// -- isaacs
-
-var path = require('path')
- , fs = require('fs')
- , Future = require('fibers/future')
-
-// Create future-returning fs functions
-var fs2 = {}
-for (var ii in fs) {
- fs2[ii] = Future.wrap(fs[ii])
-}
-
-// Return a future which just pauses for a certain amount of time
-
-function timer (ms) {
- var future = new Future
- setTimeout(function () {
- future.return()
- }, ms)
- return future
-}
-
-function realish (p) {
- return path.resolve(path.dirname(fs2.readlink(p)))
-}
-
-// for EMFILE backoff.
-var timeout = 0
- , EMFILE_MAX = 1000
-
-function rimraf_ (p, opts) {
- opts = opts || {}
- opts.maxBusyTries = opts.maxBusyTries || 3
- if (opts.gently) opts.gently = path.resolve(opts.gently)
- var busyTries = 0
-
- // exits by throwing or returning.
- // loops on handled errors.
- while (true) {
- try {
- var stat = fs2.lstat(p).wait()
-
- // check to make sure that symlinks are ours.
- if (opts.gently) {
- var rp = stat.isSymbolicLink() ? realish(p) : path.resolve(p)
- if (rp.indexOf(opts.gently) !== 0) {
- var er = new Error("Refusing to delete: "+p+" not in "+opts.gently)
- er.errno = require("constants").EEXIST
- er.code = "EEXIST"
- er.path = p
- throw er
- }
- }
-
- if (!stat.isDirectory()) return fs2.unlink(p).wait()
-
- var rimrafs = fs2.readdir(p).wait().map(function (file) {
- return rimraf(path.join(p, file), opts)
- })
-
- Future.wait(rimrafs)
- fs2.rmdir(p).wait()
- timeout = 0
- return
-
- } catch (er) {
- if (er.message.match(/^EMFILE/) && timeout < EMFILE_MAX) {
- timer(timeout++).wait()
- } else if (er.message.match(/^EBUSY/)
- && busyTries < opt.maxBusyTries) {
- timer(++busyTries * 100).wait()
- } else if (er.message.match(/^ENOENT/)) {
- // already gone
- return
- } else {
- throw er
- }
- }
- }
-}
-
-var rimraf = module.exports = rimraf_.future()
{"name":"rimraf"
-,"version":"1.0.9"
+,"version":"2.0.1"
,"main":"rimraf.js"
,"description":"A deep deletion module for node (like `rm -rf`)"
,"author":"Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
,"license":
{"type":"MIT", "url": "https://github.com/isaacs/rimraf/raw/master/LICENSE"}
+,"optionalDependencies":{"graceful-fs":"~1.1"}
,"repository":"git://github.com/isaacs/rimraf.git"
,"scripts":{"test":"cd test && bash run.sh"}}
// for EMFILE handling
var timeout = 0
- , EMFILE_MAX = 1000
+exports.EMFILE_MAX = 1000
+exports.BUSYTRIES_MAX = 3
-function rimraf (p, opts, cb) {
- if (typeof opts === "function") cb = opts, opts = {}
+function rimraf (p, cb) {
if (!cb) throw new Error("No callback passed to rimraf()")
- if (!opts) opts = {}
var busyTries = 0
- opts.maxBusyTries = opts.maxBusyTries || 3
- if (opts.gently) opts.gently = path.resolve(opts.gently)
-
- rimraf_(p, opts, function CB (er) {
+ rimraf_(p, function CB (er) {
if (er) {
- if (er.code === "EBUSY" && busyTries < opts.maxBusyTries) {
- var time = (opts.maxBusyTries - busyTries) * 100
+ if (er.code === "EBUSY" && busyTries < exports.BUSYTRIES_MAX) {
+ var time = (exports.BUSYTRIES_MAX - busyTries) * 100
busyTries ++
// try again, with the same exact callback as this one.
return setTimeout(function () {
- rimraf_(p, opts, CB)
+ rimraf_(p, CB)
})
}
// this one won't happen if graceful-fs is used.
- if (er.code === "EMFILE" && timeout < EMFILE_MAX) {
+ if (er.code === "EMFILE" && timeout < exports.EMFILE_MAX) {
return setTimeout(function () {
- rimraf_(p, opts, CB)
+ rimraf_(p, CB)
}, timeout ++)
}
})
}
-function rimraf_ (p, opts, cb) {
+function rimraf_ (p, cb) {
fs[lstat](p, function (er, s) {
- // if the stat fails, then assume it's already gone.
if (er) {
// already gone
if (er.code === "ENOENT") return cb()
return cb(er)
}
- // don't delete that don't point actually live in the "gently" path
- if (opts.gently) return clobberTest(p, s, opts, cb)
- return rm_(p, s, opts, cb)
+ return rm_(p, s, false, cb)
})
}
-function rm_ (p, s, opts, cb) {
- if (!s.isDirectory()) return fs.unlink(p, cb)
+
+var myGid = function myGid () {
+ var g = process.getuid && process.getgid()
+ myGid = function myGid () { return g }
+ return g
+}
+
+var myUid = function myUid () {
+ var u = process.getuid && process.getuid()
+ myUid = function myUid () { return u }
+ return u
+}
+
+
+function writable (s) {
+ var mode = s.mode || 0777
+ , uid = myUid()
+ , gid = myGid()
+ return (mode & 0002)
+ || (gid === s.gid && (mode & 0020))
+ || (uid === s.uid && (mode & 0200))
+}
+
+function rm_ (p, s, didWritableCheck, cb) {
+ if (!didWritableCheck && !writable(s)) {
+ // make file writable
+ // user/group/world, doesn't matter at this point
+ // since it's about to get nuked.
+ return fs.chmod(p, s.mode | 0222, function (er) {
+ if (er) return cb(er)
+ rm_(p, s, true, cb)
+ })
+ }
+
+ if (!s.isDirectory()) {
+ return fs.unlink(p, cb)
+ }
+
+ // directory
fs.readdir(p, function (er, files) {
if (er) return cb(er)
asyncForEach(files.map(function (f) {
return path.join(p, f)
}), function (file, cb) {
- rimraf(file, opts, cb)
+ rimraf(file, cb)
}, function (er) {
if (er) return cb(er)
fs.rmdir(p, cb)
})
}
-function clobberTest (p, s, opts, cb) {
- var gently = opts.gently
- if (!s.isSymbolicLink()) next(null, path.resolve(p))
- else realish(p, next)
-
- function next (er, rp) {
- if (er) return rm_(p, s, cb)
- if (rp.indexOf(gently) !== 0) return clobberFail(p, gently, cb)
- else return rm_(p, s, opts, cb)
- }
-}
-
-function realish (p, cb) {
- fs.readlink(p, function (er, r) {
- if (er) return cb(er)
- return cb(null, path.resolve(path.dirname(p), r))
- })
-}
-
-function clobberFail (p, g, cb) {
- var er = new Error("Refusing to delete: "+p+" not in "+g)
- , constants = require("constants")
- er.errno = constants.EEXIST
- er.code = "EEXIST"
- er.path = p
- return cb(er)
-}
-
function asyncForEach (list, fn, cb) {
if (!list.length) cb()
var c = list.length
if (er.code === "ENOENT") return
throw er
}
+
+ if (!writable(s)) {
+ fs.chmodSync(p, s.mode | 0222)
+ }
+
if (!s.isDirectory()) return fs.unlinkSync(p)
+
fs.readdirSync(p).forEach(function (f) {
rimrafSync(path.join(p, f))
})
opts.type = "Directory"
opts.Directory = true
+ // similar to --strip or --strip-components
+ opts.strip = +opts.strip
+ if (!opts.strip || opts.strip <= 0) opts.strip = 0
+
this._fst = fstream.Writer(opts)
this.pause()
// of the tarball. So, they need to be resolved against
// the target directory in order to be created properly.
me.on("entry", function (entry) {
+ // if there's a "strip" argument, then strip off that many
+ // path components.
+ if (opts.strip) {
+ var p = entry.path.split("/").slice(opts.strip).join("/")
+ entry.path = entry.props.path = p
+ if (entry.linkpath) {
+ var lp = entry.linkpath.split("/").slice(opts.strip).join("/")
+ entry.linkpath = entry.props.linkpath = lp
+ }
+ }
if (entry.type !== "Link") return
entry.linkpath = entry.props.linkpath =
path.join(opts.path, path.join("/", entry.props.linkpath))
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
"name": "tar",
"description": "tar for node",
- "version": "0.1.12",
+ "version": "0.1.13",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-tar.git"
"devDependencies": {
"tap": "0.x",
"rimraf": "1.x"
- }
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "tar@0.1.13",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.4",
+ "_nodeVersion": "v0.7.6-pre",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "804bdaaacaab928ec1c9bbd8b848a042c3adacb2"
+ },
+ "_from": "tar@0.1.13"
}
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me"
+ },
"name": "which",
"description": "Like which(1) unix command. Find the first instance of an executable in the PATH.",
- "version": "1.0.2",
+ "version": "1.0.5",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-which.git"
},
"main": "which.js",
- "bin": "./bin/which",
+ "bin": {
+ "which": "./bin/which"
+ },
"engines": {
"node": "*"
},
"dependencies": {},
- "devDependencies": {}
+ "devDependencies": {},
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "which@1.0.5",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.2",
+ "_nodeVersion": "v0.7.6-pre",
+ "_defaultsLoaded": true,
+ "_from": "which@1"
}
var path = require("path")
, fs
, COLON = process.platform === "win32" ? ";" : ":"
+ , isExe
try {
fs = require("graceful-fs")
fs = require("fs")
}
-// console.log(process.execPath)
-// console.log(process.argv)
-
-function isExe (mod, uid, gid) {
- //console.error("isExe?", (mod & 0111).toString(8))
- var ret = (mod & 0001)
- || (mod & 0010) && process.getgid && gid === process.getgid()
- || (mod & 0100) && process.getuid && uid === process.getuid()
- //console.error("isExe?", ret)
- return ret
+if (process.platform == "win32") {
+ // On windows, there is no good way to check that a file is executable
+ isExe = function isExe () { return true }
+} else {
+ isExe = function isExe (mod, uid, gid) {
+ //console.error(mod, uid, gid);
+ //console.error("isExe?", (mod & 0111).toString(8))
+ var ret = (mod & 0001)
+ || (mod & 0010) && process.getgid && gid === process.getgid()
+ || (mod & 0100) && process.getuid && uid === process.getuid()
+ //console.error("isExe?", ret)
+ return ret
+ }
}
+
+
+
function which (cmd, cb) {
- if (cmd.charAt(0) === "/") return cb(null, cmd)
+ if (isAbsolute(cmd)) return cb(null, cmd)
var pathEnv = (process.env.PATH || "").split(COLON)
, pathExt = [""]
if (process.platform === "win32") {
pathEnv.push(process.cwd())
pathExt = (process.env.PATHEXT || ".EXE").split(COLON)
+ if (cmd.indexOf(".") !== -1) pathExt.unshift("")
}
//console.error("pathEnv", pathEnv)
;(function F (i, l) {
})(0, pathEnv.length)
}
-
function whichSync (cmd) {
- if (cmd.charAt(0) === "/") return cmd
+ if (isAbsolute(cmd)) return cmd
var pathEnv = (process.env.PATH || "").split(COLON)
+ , pathExt = [""]
+ if (process.platform === "win32") {
+ pathEnv.push(process.cwd())
+ pathExt = (process.env.PATHEXT || ".EXE").split(COLON)
+ if (cmd.indexOf(".") !== -1) pathExt.unshift("")
+ }
for (var i = 0, l = pathEnv.length; i < l; i ++) {
var p = path.join(pathEnv[i], cmd)
- if (p === process.execPath) return p
- var stat
- try { stat = fs.statSync(p) } catch (ex) {}
- if (stat && isExe(stat.mode, stat.uid, stat.gid)) return p
+ for (var j = 0, ll = pathExt.length; j < ll; j ++) {
+ var cur = p + pathExt[j]
+ var stat
+ try { stat = fs.statSync(cur) } catch (ex) {}
+ if (stat &&
+ stat.isFile() &&
+ isExe(stat.mode, stat.uid, stat.gid)) return cur
+ }
}
throw new Error("not found: "+cmd)
}
+
+var isAbsolute = process.platform === "win32" ? absWin : absUnix
+
+function absWin (p) {
+ if (absUnix(p)) return true
+ // pull off the device/UNC bit from a windows path.
+ // from node's lib/path.js
+ var splitDeviceRe =
+ /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?/
+ , result = splitDeviceRe.exec(p)
+ , device = result[1] || ''
+ , isUnc = device && device.charAt(1) !== ':'
+ , isAbsolute = !!result[2] || isUnc // UNC paths are always absolute
+
+ return isAbsolute
+}
+
+function absUnix (p) {
+ return p.charAt(0) === "/" || p === ""
+}
"install",
"package.json"
],
- "version": "1.1.0-2",
+ "version": "1.1.21",
"preferGlobal": true,
"config": {
"publishtest": false
"slide": "1",
"abbrev": "1",
"graceful-fs": "~1.1.1",
- "minimatch": "0",
+ "minimatch": "~0.2",
"nopt": "1",
"node-uuid": "~1.3",
"proto-list": "1",
- "rimraf": "1",
+ "rimraf": "2",
"request": "~2.9",
"which": "1",
"tar": "~0.1.12",
- "fstream": "~0.1.5",
+ "fstream": "~0.1.17",
"block-stream": "*",
"inherits": "1",
- "mkdirp": "0.1",
- "fast-list": "~1.0.1",
+ "mkdirp": "0.3",
"read": "0",
- "lru-cache": "1"
+ "lru-cache": "1",
+ "node-gyp": "~0.4.1",
+ "fstream-npm": "0 >=0.0.5",
+ "uid-number": "0",
+ "archy": "0",
+ "chownr": "0"
},
"bundleDependencies": [
"slide",
"block-stream",
"inherits",
"mkdirp",
- "fast-list",
"read",
- "lru-cache"
+ "lru-cache",
+ "node-gyp",
+ "fstream-npm",
+ "uid-number",
+ "archy",
+ "chownr"
],
"devDependencies": {
"ronn": "https://github.com/isaacs/ronnjs/tarball/master"
function done (which) { return function (er, docs) {
if (er) throw er
+ docs.sort()
if (which === "api") apidocs = docs
else clidocs = docs
{ "name":"npm-test-env-reader"
, "version" : "1.2.3"
, "scripts" :
- { "install" : "./test.sh"
- , "preinstall" : "./test.sh"
- , "preuninstall" : "./test.sh"
- , "postuninstall" : "./test.sh"
- , "test" : "./test.sh"
- , "stop" : "./test.sh"
- , "start" : "./test.sh"
- , "restart" : "./test.sh"
- , "foo" : "./test.sh"
+ { "install" : "node test.js"
+ , "preinstall" : "node test.js"
+ , "preuninstall" : "node test.js"
+ , "postuninstall" : "node test.js"
+ , "test" : "node test.js"
+ , "stop" : "node test.js"
+ , "start" : "node test.js"
+ , "restart" : "node test.js"
+ , "foo" : "node test.js"
}
}
+++ /dev/null
-#!/usr/bin/env sh
-env | grep npm | sort | uniq
-echo PATH=$PATH
, "sub/include"
, "sub/include2"
, "sub/include4"
- , "test.sh" ]
+ , "test.sh"
+ , ".npmignore" ]
, "scripts":{"test":"bash test.sh"}}
{ "name": "npm-test-optional-deps"
, "version": "1.2.5"
+, "scripts": { "test": "node test.js" }
, "optionalDependencies":
{ "npm-test-foobarzaaakakaka": "http://example.com/"
, "dnode": "10.999.14234"
- , "sax": "*"
+ , "sax": "0.3.5"
, "999 invalid name": "1.2.3"
, "glob": "some invalid version 99 #! $$ x y z"
+ , "npm-test-failer":"*"
}
}