## SYNOPSIS
- npm docs <pkgname>
+ npm docs [<pkgname> [<pkgname> ...]]
npm docs (with no args in a package dir)
- npm home <pkgname>
+ npm home [<pkgname> [<pkgname> ...]]
npm home (with no args in a package dir)
## DESCRIPTION
This command tries to guess at the likely location of a package's
documentation URL, and then tries to open it using the `--browser`
-config param. If no package name is provided, it will search for
-a `package.json` in the current folder and use the `name` property.
+config param. You can pass multiple package names at once. If no
+package name is provided, it will search for a `package.json` in
+the current folder and use the `name` property.
## CONFIGURATION
## SYNOPSIS
- npm search [search terms ...]
+ npm search [--long] [search terms ...]
npm s [search terms ...]
npm se [search terms ...]
A trailing `/` will be ignored in this case. (Note that many regular
expression characters must be escaped or quoted in most shells.)
+## CONFIGURATION
+
+### long
+
+* Default: false
+* Type: Boolean
+
+Display full package descriptions and other long text across multiple
+lines. When disabled (default) search results are truncated to fit
+neatly on a single line. Modules with extremely long names will
+fall on multiple lines.
+
## SEE ALSO
* npm-registry(7)
* Default: false
* Type: Boolean
-Show extended information in `npm ls`
+Show extended information in `npm ls` and `npm search`.
### message
<ul><li><a href="cli/npm.html">npm(1)</a></li><li><a href="misc/npm-faq.html">npm-faq(7)</a></li><li><a href="cli/npm-help.html">npm-help(1)</a></li><li><a href="misc/npm-index.html">npm-index(7)</a></li></ul>
</div>
-<p id="footer"><a href="../doc/README.html">README</a> — npm@1.3.23</p>
+<p id="footer"><a href="../doc/README.html">README</a> — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function should not be used programmatically. Instead, just refer
to the <code>npm.bin</code> member.</p>
</div>
-<p id="footer">npm-bin — npm@1.3.23</p>
+<p id="footer">npm-bin — npm@1.3.24</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">npm-bugs — npm@1.3.23</p>
+<p id="footer">npm-bugs — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-index.html">npm-index(7)</a></li></ul>
</div>
-<p id="footer">npm-commands — npm@1.3.23</p>
+<p id="footer">npm-commands — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/npm.html">npm(3)</a></li></ul>
</div>
-<p id="footer">npm-config — npm@1.3.23</p>
+<p id="footer">npm-config — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/npm-publish.html">npm-publish(3)</a></li><li><a href="../api/npm-unpublish.html">npm-unpublish(3)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li></ul>
</div>
-<p id="footer">npm-deprecate — npm@1.3.23</p>
+<p id="footer">npm-deprecate — npm@1.3.24</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">npm-docs — npm@1.3.23</p>
+<p id="footer">npm-docs — npm@1.3.24</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">npm-edit — npm@1.3.23</p>
+<p id="footer">npm-edit — npm@1.3.24</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">npm-explore — npm@1.3.23</p>
+<p id="footer">npm-explore — npm@1.3.24</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">npm-help-search — npm@1.3.23</p>
+<p id="footer">npm-help-search — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p><a href="../files/package.json.html">package.json(5)</a></p>
</div>
-<p id="footer">npm-init — npm@1.3.23</p>
+<p id="footer">npm-init — npm@1.3.24</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">npm-install — npm@1.3.23</p>
+<p id="footer">npm-install — npm@1.3.24</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">npm-link — npm@1.3.23</p>
+<p id="footer">npm-link — npm@1.3.24</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">npm-load — npm@1.3.23</p>
+<p id="footer">npm-load — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
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">npm-ls — npm@1.3.23</p>
+<p id="footer">npm-ls — npm@1.3.24</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">npm-outdated — npm@1.3.23</p>
+<p id="footer">npm-outdated — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/npm-publish.html">npm-publish(3)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li></ul>
</div>
-<p id="footer">npm-owner — npm@1.3.23</p>
+<p id="footer">npm-owner — npm@1.3.24</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">npm-pack — npm@1.3.23</p>
+<p id="footer">npm-pack — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically</p>
</div>
-<p id="footer">npm-prefix — npm@1.3.23</p>
+<p id="footer">npm-prefix — npm@1.3.24</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">npm-prune — npm@1.3.23</p>
+<p id="footer">npm-prune — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li><li><a href="../api/npm-owner.html">npm-owner(3)</a></li></ul>
</div>
-<p id="footer">npm-publish — npm@1.3.23</p>
+<p id="footer">npm-publish — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>See <code>npm help build</code></p>
</div>
-<p id="footer">npm-rebuild — npm@1.3.23</p>
+<p id="footer">npm-rebuild — npm@1.3.24</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">npm-repo — npm@1.3.23</p>
+<p id="footer">npm-repo — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../api/npm-start.html">npm-start(3)</a></li><li><a href="../api/npm-stop.html">npm-stop(3)</a></li></ul>
</div>
-<p id="footer">npm-restart — npm@1.3.23</p>
+<p id="footer">npm-restart — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically.</p>
</div>
-<p id="footer">npm-root — npm@1.3.23</p>
+<p id="footer">npm-root — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../api/npm-test.html">npm-test(3)</a></li><li><a href="../api/npm-start.html">npm-start(3)</a></li><li><a href="../api/npm-restart.html">npm-restart(3)</a></li><li><a href="../api/npm-stop.html">npm-stop(3)</a></li></ul>
</div>
-<p id="footer">npm-run-script — npm@1.3.23</p>
+<p id="footer">npm-run-script — npm@1.3.24</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">npm-search — npm@1.3.23</p>
+<p id="footer">npm-search — npm@1.3.24</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">npm-shrinkwrap — npm@1.3.23</p>
+<p id="footer">npm-shrinkwrap — npm@1.3.24</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">npm-start — npm@1.3.23</p>
+<p id="footer">npm-start — npm@1.3.24</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">npm-stop — npm@1.3.23</p>
+<p id="footer">npm-stop — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li>npm help json</li><li>git help submodule</li></ul>
</div>
-<p id="footer">npm-submodule — npm@1.3.23</p>
+<p id="footer">npm-submodule — npm@1.3.24</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">npm-tag — npm@1.3.23</p>
+<p id="footer">npm-tag — npm@1.3.24</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">npm-test — npm@1.3.23</p>
+<p id="footer">npm-test — npm@1.3.24</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">npm-uninstall — npm@1.3.23</p>
+<p id="footer">npm-uninstall — npm@1.3.24</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">npm-unpublish — npm@1.3.23</p>
+<p id="footer">npm-unpublish — npm@1.3.24</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">npm-update — npm@1.3.23</p>
+<p id="footer">npm-update — npm@1.3.24</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">npm-version — npm@1.3.23</p>
+<p id="footer">npm-version — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>corresponding to the list of fields selected.</p>
</div>
-<p id="footer">npm-view — npm@1.3.23</p>
+<p id="footer">npm-view — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>This function is not useful programmatically</p>
</div>
-<p id="footer">npm-whoami — npm@1.3.23</p>
+<p id="footer">npm-whoami — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="VERSION">VERSION</h2>
-<p>1.3.23</p>
+<p>1.3.24</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<pre><code>var cmd = npm.deref("unp") // cmd === "unpublish"</code></pre>
</div>
-<p id="footer">npm — npm@1.3.23</p>
+<p id="footer">npm — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../cli/npm-owner.html">npm-owner(1)</a></li><li><a href="../cli/npm-whoami.html">npm-whoami(1)</a></li></ul>
</div>
-<p id="footer">npm-adduser — npm@1.3.23</p>
+<p id="footer">npm-adduser — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-prefix.html">npm-prefix(1)</a></li><li><a href="../cli/npm-root.html">npm-root(1)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-bin — npm@1.3.23</p>
+<p id="footer">npm-bin — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-docs.html">npm-docs(1)</a></li><li><a href="../cli/npm-view.html">npm-view(1)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li></ul>
</div>
-<p id="footer">npm-bugs — npm@1.3.23</p>
+<p id="footer">npm-bugs — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-link.html">npm-link(1)</a></li><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li></ul>
</div>
-<p id="footer">npm-build — npm@1.3.23</p>
+<p id="footer">npm-build — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-install.html">npm-install(1)</a></li></ul>
</div>
-<p id="footer">npm-bundle — npm@1.3.23</p>
+<p id="footer">npm-bundle — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../cli/npm-pack.html">npm-pack(1)</a></li></ul>
</div>
-<p id="footer">npm-cache — npm@1.3.23</p>
+<p id="footer">npm-cache — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-developers.html">npm-developers(7)</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../cli/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">npm-completion — npm@1.3.23</p>
+<p id="footer">npm-completion — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../cli/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">npm-config — npm@1.3.23</p>
+<p id="footer">npm-config — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-ls.html">npm-ls(1)</a></li><li><a href="../cli/npm-update.html">npm-update(1)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li></ul>
</div>
-<p id="footer">npm-dedupe — npm@1.3.23</p>
+<p id="footer">npm-dedupe — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li></ul>
</div>
-<p id="footer">npm-deprecate — npm@1.3.23</p>
+<p id="footer">npm-deprecate — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="SYNOPSIS">SYNOPSIS</h2>
-<pre><code>npm docs <pkgname>
+<pre><code>npm docs [<pkgname> [<pkgname> ...]]
npm docs (with no args in a package dir)
-npm home <pkgname>
+npm home [<pkgname> [<pkgname> ...]]
npm home (with no args in a package dir)</code></pre>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<p>This command tries to guess at the likely location of a package's
documentation URL, and then tries to open it using the <code>--browser</code>
-config param. If no package name is provided, it will search for
-a <code>package.json</code> in the current folder and use the <code>name</code> property.</p>
+config param. You can pass multiple package names at once. If no
+package name is provided, it will search for a <code>package.json</code> in
+the current folder and use the <code>name</code> property.</p>
<h2 id="CONFIGURATION">CONFIGURATION</h2>
<ul><li><a href="../cli/npm-view.html">npm-view(1)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li></ul>
</div>
-<p id="footer">npm-docs — npm@1.3.23</p>
+<p id="footer">npm-docs — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-explore.html">npm-explore(1)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-edit — npm@1.3.23</p>
+<p id="footer">npm-edit — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-submodule.html">npm-submodule(1)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-edit.html">npm-edit(1)</a></li><li><a href="../cli/npm-rebuild.html">npm-rebuild(1)</a></li><li><a href="../cli/npm-build.html">npm-build(1)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li></ul>
</div>
-<p id="footer">npm-explore — npm@1.3.23</p>
+<p id="footer">npm-explore — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm.html">npm(1)</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../cli/npm-help.html">npm-help(1)</a></li></ul>
</div>
-<p id="footer">npm-help-search — npm@1.3.23</p>
+<p id="footer">npm-help-search — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm.html">npm(1)</a></li><li><a href="../../doc/README.html">README</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm-help-search.html">npm-help-search(1)</a></li><li><a href="../misc/npm-index.html">npm-index(7)</a></li></ul>
</div>
-<p id="footer">npm-help — npm@1.3.23</p>
+<p id="footer">npm-help — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="https://github.com/isaacs/init-package-json">https://github.com/isaacs/init-package-json</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm-version.html">npm-version(1)</a></li></ul>
</div>
-<p id="footer">npm-init — npm@1.3.23</p>
+<p id="footer">npm-init — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-update.html">npm-update(1)</a></li><li><a href="../cli/npm-link.html">npm-link(1)</a></li><li><a href="../cli/npm-rebuild.html">npm-rebuild(1)</a></li><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../cli/npm-build.html">npm-build(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-tag.html">npm-tag(1)</a></li><li><a href="../cli/npm-rm.html">npm-rm(1)</a></li><li><a href="../cli/npm-shrinkwrap.html">npm-shrinkwrap(1)</a></li></ul>
</div>
-<p id="footer">npm-install — npm@1.3.23</p>
+<p id="footer">npm-install — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-developers.html">npm-developers(7)</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-link — npm@1.3.23</p>
+<p id="footer">npm-link — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
nested packages will <em>also</em> show the paths to the specified packages.
For example, running <code>npm ls promzard</code> in npm's source tree will show:</p>
-<pre><code>npm@1.3.23 /path/to/npm
+<pre><code>npm@1.3.24 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5</code></pre>
<ul><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-link.html">npm-link(1)</a></li><li><a href="../cli/npm-prune.html">npm-prune(1)</a></li><li><a href="../cli/npm-outdated.html">npm-outdated(1)</a></li><li><a href="../cli/npm-update.html">npm-update(1)</a></li></ul>
</div>
-<p id="footer">npm-ls — npm@1.3.23</p>
+<p id="footer">npm-ls — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-update.html">npm-update(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li></ul>
</div>
-<p id="footer">npm-outdated — npm@1.3.23</p>
+<p id="footer">npm-outdated — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li><li><a href="../misc/npm-disputes.html">npm-disputes(7)</a></li></ul>
</div>
-<p id="footer">npm-owner — npm@1.3.23</p>
+<p id="footer">npm-owner — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-cache.html">npm-cache(1)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-pack — npm@1.3.23</p>
+<p id="footer">npm-pack — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-root.html">npm-root(1)</a></li><li><a href="../cli/npm-bin.html">npm-bin(1)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-prefix — npm@1.3.23</p>
+<p id="footer">npm-prefix — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-rm.html">npm-rm(1)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-ls.html">npm-ls(1)</a></li></ul>
</div>
-<p id="footer">npm-prune — npm@1.3.23</p>
+<p id="footer">npm-prune — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li><li><a href="../cli/npm-owner.html">npm-owner(1)</a></li><li><a href="../cli/npm-deprecate.html">npm-deprecate(1)</a></li><li><a href="../cli/npm-tag.html">npm-tag(1)</a></li></ul>
</div>
-<p id="footer">npm-publish — npm@1.3.23</p>
+<p id="footer">npm-publish — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-build.html">npm-build(1)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li></ul>
</div>
-<p id="footer">npm-rebuild — npm@1.3.23</p>
+<p id="footer">npm-rebuild — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-docs.html">npm-docs(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li></ul>
</div>
-<p id="footer">npm-repo — npm@1.3.23</p>
+<p id="footer">npm-repo — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-run-script.html">npm-run-script(1)</a></li><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../cli/npm-test.html">npm-test(1)</a></li><li><a href="../cli/npm-start.html">npm-start(1)</a></li><li><a href="../cli/npm-stop.html">npm-stop(1)</a></li></ul>
</div>
-<p id="footer">npm-restart — npm@1.3.23</p>
+<p id="footer">npm-restart — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-prune.html">npm-prune(1)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-rm — npm@1.3.23</p>
+<p id="footer">npm-rm — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-prefix.html">npm-prefix(1)</a></li><li><a href="../cli/npm-bin.html">npm-bin(1)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-root — npm@1.3.23</p>
+<p id="footer">npm-root — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../cli/npm-test.html">npm-test(1)</a></li><li><a href="../cli/npm-start.html">npm-start(1)</a></li><li><a href="../cli/npm-restart.html">npm-restart(1)</a></li><li><a href="../cli/npm-stop.html">npm-stop(1)</a></li></ul>
</div>
-<p id="footer">npm-run-script — npm@1.3.23</p>
+<p id="footer">npm-run-script — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="SYNOPSIS">SYNOPSIS</h2>
-<pre><code>npm search [search terms ...]
+<pre><code>npm search [--long] [search terms ...]
npm s [search terms ...]
npm se [search terms ...]</code></pre>
A trailing <code>/</code> will be ignored in this case. (Note that many regular
expression characters must be escaped or quoted in most shells.)</p>
+<h2 id="CONFIGURATION">CONFIGURATION</h2>
+
+<h3 id="long">long</h3>
+
+<ul><li>Default: false</li><li>Type: Boolean</li></ul>
+
+<p>Display full package descriptions and other long text across multiple
+lines. When disabled (default) search results are truncated to fit
+neatly on a single line. Modules with extremely long names will
+fall on multiple lines.</p>
+
<h2 id="SEE-ALSO">SEE ALSO</h2>
<ul><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../cli/npm-view.html">npm-view(1)</a></li></ul>
</div>
-<p id="footer">npm-search — npm@1.3.23</p>
+<p id="footer">npm-search — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm-ls.html">npm-ls(1)</a></li></ul>
</div>
-<p id="footer">npm-shrinkwrap — npm@1.3.23</p>
+<p id="footer">npm-shrinkwrap — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-view.html">npm-view(1)</a></li><li><a href="../cli/npm-whoami.html">npm-whoami(1)</a></li><li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li></ul>
</div>
-<p id="footer">npm-star — npm@1.3.23</p>
+<p id="footer">npm-star — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-star.html">npm-star(1)</a></li><li><a href="../cli/npm-view.html">npm-view(1)</a></li><li><a href="../cli/npm-whoami.html">npm-whoami(1)</a></li><li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li></ul>
</div>
-<p id="footer">npm-stars — npm@1.3.23</p>
+<p id="footer">npm-stars — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-run-script.html">npm-run-script(1)</a></li><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../cli/npm-test.html">npm-test(1)</a></li><li><a href="../cli/npm-restart.html">npm-restart(1)</a></li><li><a href="../cli/npm-stop.html">npm-stop(1)</a></li></ul>
</div>
-<p id="footer">npm-start — npm@1.3.23</p>
+<p id="footer">npm-start — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-run-script.html">npm-run-script(1)</a></li><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../cli/npm-test.html">npm-test(1)</a></li><li><a href="../cli/npm-start.html">npm-start(1)</a></li><li><a href="../cli/npm-restart.html">npm-restart(1)</a></li></ul>
</div>
-<p id="footer">npm-stop — npm@1.3.23</p>
+<p id="footer">npm-stop — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../files/package.json.html">package.json(5)</a></li><li>git help submodule</li></ul>
</div>
-<p id="footer">npm-submodule — npm@1.3.23</p>
+<p id="footer">npm-submodule — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-dedupe.html">npm-dedupe(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-tag — npm@1.3.23</p>
+<p id="footer">npm-tag — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-run-script.html">npm-run-script(1)</a></li><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../cli/npm-start.html">npm-start(1)</a></li><li><a href="../cli/npm-restart.html">npm-restart(1)</a></li><li><a href="../cli/npm-stop.html">npm-stop(1)</a></li></ul>
</div>
-<p id="footer">npm-test — npm@1.3.23</p>
+<p id="footer">npm-test — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-prune.html">npm-prune(1)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li></ul>
</div>
-<p id="footer">npm-uninstall — npm@1.3.23</p>
+<p id="footer">npm-uninstall — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-deprecate.html">npm-deprecate(1)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li><li><a href="../cli/npm-owner.html">npm-owner(1)</a></li></ul>
</div>
-<p id="footer">npm-unpublish — npm@1.3.23</p>
+<p id="footer">npm-unpublish — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-outdated.html">npm-outdated(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-ls.html">npm-ls(1)</a></li></ul>
</div>
-<p id="footer">npm-update — npm@1.3.23</p>
+<p id="footer">npm-update — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-init.html">npm-init(1)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../misc/semver.html">semver(7)</a></li></ul>
</div>
-<p id="footer">npm-version — npm@1.3.23</p>
+<p id="footer">npm-version — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-search.html">npm-search(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../cli/npm-docs.html">npm-docs(1)</a></li></ul>
</div>
-<p id="footer">npm-view — npm@1.3.23</p>
+<p id="footer">npm-view — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li></ul>
</div>
-<p id="footer">npm-whoami — npm@1.3.23</p>
+<p id="footer">npm-whoami — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<h2 id="VERSION">VERSION</h2>
-<p>1.3.23</p>
+<p>1.3.24</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<ul><li><a href="../cli/npm-help.html">npm-help(1)</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../../doc/README.html">README</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../misc/npm-index.html">npm-index(7)</a></li><li><a href="../api/npm.html">npm(3)</a></li></ul>
</div>
-<p id="footer">npm — npm@1.3.23</p>
+<p id="footer">npm — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-pack.html">npm-pack(1)</a></li><li><a href="../cli/npm-cache.html">npm-cache(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li></ul>
</div>
-<p id="footer">npm-folders — npm@1.3.23</p>
+<p id="footer">npm-folders — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-pack.html">npm-pack(1)</a></li><li><a href="../cli/npm-cache.html">npm-cache(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li></ul>
</div>
-<p id="footer">npm-folders — npm@1.3.23</p>
+<p id="footer">npm-folders — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/semver.html">semver(7)</a></li><li><a href="../cli/npm-init.html">npm-init(1)</a></li><li><a href="../cli/npm-version.html">npm-version(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../cli/npm-help.html">npm-help(1)</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../cli/npm-rm.html">npm-rm(1)</a></li></ul>
</div>
-<p id="footer">package.json — npm@1.3.23</p>
+<p id="footer">package.json — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">npmrc — npm@1.3.23</p>
+<p id="footer">npmrc — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/semver.html">semver(7)</a></li><li><a href="../cli/npm-init.html">npm-init(1)</a></li><li><a href="../cli/npm-version.html">npm-version(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../cli/npm-help.html">npm-help(1)</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../cli/npm-rm.html">npm-rm(1)</a></li></ul>
</div>
-<p id="footer">package.json — npm@1.3.23</p>
+<p id="footer">package.json — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The semantic versioner for npm</p>
</div>
-<p id="footer">npm-index — npm@1.3.23</p>
+<p id="footer">npm-index — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-developers.html">npm-developers(7)</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../cli/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">npm-coding-style — npm@1.3.23</p>
+<p id="footer">npm-coding-style — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li>Default: false</li><li>Type: Boolean</li></ul>
-<p>Show extended information in <code>npm ls</code></p>
+<p>Show extended information in <code>npm ls</code> and <code>npm search</code>.</p>
<h3 id="message">message</h3>
<ul><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li><li><a href="../cli/npm.html">npm(1)</a></li></ul>
</div>
-<p id="footer">npm-config — npm@1.3.23</p>
+<p id="footer">npm-config — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../cli/npm.html">npm(1)</a></li><li><a href="../cli/npm-init.html">npm-init(1)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../misc/npm-scripts.html">npm-scripts(7)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../cli/npm-adduser.html">npm-adduser(1)</a></li><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li></ul>
</div>
-<p id="footer">npm-developers — npm@1.3.23</p>
+<p id="footer">npm-developers — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../misc/npm-registry.html">npm-registry(7)</a></li><li><a href="../cli/npm-owner.html">npm-owner(1)</a></li></ul>
</div>
-<p id="footer">npm-disputes — npm@1.3.23</p>
+<p id="footer">npm-disputes — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm.html">npm(1)</a></li><li><a href="../misc/npm-developers.html">npm-developers(7)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npm-folders.html">npm-folders(5)</a></li></ul>
</div>
-<p id="footer">npm-faq — npm@1.3.23</p>
+<p id="footer">npm-faq — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<p>The semantic versioner for npm</p>
</div>
-<p id="footer">npm-index — npm@1.3.23</p>
+<p id="footer">npm-index — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../files/npmrc.html">npmrc(5)</a></li><li><a href="../misc/npm-developers.html">npm-developers(7)</a></li><li><a href="../misc/npm-disputes.html">npm-disputes(7)</a></li></ul>
</div>
-<p id="footer">npm-registry — npm@1.3.23</p>
+<p id="footer">npm-registry — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../cli/npm-run-script.html">npm-run-script(1)</a></li><li><a href="../files/package.json.html">package.json(5)</a></li><li><a href="../misc/npm-developers.html">npm-developers(7)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li></ul>
</div>
-<p id="footer">npm-scripts — npm@1.3.23</p>
+<p id="footer">npm-scripts — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
<ul><li><a href="../../doc/README.html">README</a></li><li><a href="../cli/npm-rm.html">npm-rm(1)</a></li><li><a href="../cli/npm-prune.html">npm-prune(1)</a></li></ul>
</div>
-<p id="footer">removing-npm — npm@1.3.23</p>
+<p id="footer">removing-npm — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
range.</li><li>maxSatisfying(versions, range): Return the highest version in the list
that satisfies the range, or null if none of them do.</li></ul>
</div>
-<p id="footer">semver — npm@1.3.23</p>
+<p id="footer">semver — npm@1.3.24</p>
<script>
;(function () {
var wrapper = document.getElementById("wrapper")
function readUsername (c, u, cb) {
var v = userValidate.username
- read({prompt: "Username: ", default: c.u}, function (er, un) {
+ read({prompt: "Username: ", default: c.u || ""}, function (er, un) {
if (er) {
return cb(er.message === "cancelled" ? er.message : er)
}
function readEmail (c, u, cb) {
var v = userValidate.email
-
- read({prompt: "Email: (this IS public) ", default: c.e}, function (er, em) {
+ var r = { prompt: "Email: (this IS public) ", default: c.e || "" }
+ read(r, function (er, em) {
if (er) {
return cb(er.message === "cancelled" ? er.message : er)
}
docs.usage += "npm docs ."
docs.completion = function (opts, cb) {
- if (opts.conf.argv.remain.length > 2) return cb()
registry.get("/-/short", 60000, function (er, list) {
return cb(null, list || [])
})
}
function docs (args, cb) {
- var project = args[0] || '.'
- , package = path.resolve(process.cwd(), "package.json")
+ args = args || []
+ var pending = args.length
+ if (!pending) return getDoc('.', cb)
+ args.forEach(function(proj) {
+ getDoc(proj, function(err) {
+ if (err) return cb(err)
+ --pending || cb()
+ })
+ })
+}
+
+function getDoc (project, cb) {
+ project = project || '.'
+ var package = path.resolve(process.cwd(), "package.json")
if (project === '.' || project === './') {
try {
return cb(null, d.name)
}
- // something is there, but it's not satisfactory. Clobber it.
- return cb(null, [])
+ // see if the package had been previously linked
+ fs.lstat(path.resolve(nm, pkg), function(err, s) {
+ if (err) return cb(null, [])
+ if (s.isSymbolicLink()) {
+ return cb(null, d.name)
+ }
+
+ // something is there, but it's not satisfactory. Clobber it.
+ return cb(null, [])
+ })
})
}, function (er, inst) {
// this is the list of things that are valid and should be ignored.
what = what + "@" + deps[what]
}
+ // This is where we actually fetch the package, if it's not already
+ // in the cache.
+ // If it's a git repo, then we want to install it, even if the parent
+ // already has a matching copy.
+ // If it's not a git repo, and the parent already has that pkg, then
+ // we can skip installing it again.
cache.add(what, function (er, data) {
if (er && parent && parent.optionalDependencies &&
parent.optionalDependencies.hasOwnProperty(what.split("@")[0])) {
return cb(null, [])
}
- // if the target is a git repository, we always want to fetch it
var isGit = false
- , maybeGit = what.split("@").pop()
+ , maybeGit = what.split("@").slice(1).join()
if (maybeGit)
isGit = isGitUrl(url.parse(maybeGit))
prune.completion = require("./utils/completion/installed-deep.js")
function prune (args, cb) {
+ //check if is a valid package.json file
var jsonFile = path.resolve(npm.dir, "..", "package.json" )
- readJson(jsonFile, log.warn, function (er, packageData) {
+ readJson(jsonFile, log.warn, function (er, data) {
if (er) return cb(er)
+ next()
+ })
+
+ function next() {
readInstalled(npm.prefix, npm.config.get("depth"), function (er, data) {
if (er) return cb(er)
- if (npm.config.get("production")) {
- Object.keys(packageData.devDependencies || {}).forEach(function (k) {
- if (data.dependencies[k]) data.dependencies[k].extraneous = true
- })
- }
prune_(args, data, cb)
})
- })
+ }
}
function prune_ (args, data, cb) {
var npm = require("./npm.js")
, registry = npm.registry
+ , columnify = require('columnify')
search.usage = "npm search [some search terms ...]"
&& (new Date(data.time.modified).toISOString()
.split("T").join(" ")
.replace(/:[0-9]{2}\.[0-9]{3}Z$/, ""))
- || "(prehistoric)"
+ .slice(0, -5) // remove time
+ || "prehistoric"
}
}
}
function prettify (data, args) {
- try {
- var tty = require("tty")
- , stdout = process.stdout
- , cols = !tty.isatty(stdout.fd) ? Infinity
- : process.stdout.getWindowSize()[0]
- cols = (cols == 0) ? Infinity : cols
- } catch (ex) { cols = Infinity }
-
- // name, desc, author, keywords
- var longest = []
- , spaces
- , maxLen = npm.config.get("description")
- ? [20, 60, 20, 20, 10, Infinity]
- : [20, 20, 20, 10, Infinity]
- , headings = npm.config.get("description")
- ? ["NAME", "DESCRIPTION", "AUTHOR", "DATE", "VERSION", "KEYWORDS"]
- : ["NAME", "AUTHOR", "DATE", "VERSION", "KEYWORDS"]
- , lines
- , searchsort = (npm.config.get("searchsort") || "NAME").toLowerCase()
- , sortFields = { name: 0
- , description: 1
- , author: 2
- , date: 3
- , version: 4
- , keywords: 5 }
+ var searchsort = (npm.config.get("searchsort") || "NAME").toLowerCase()
+ , sortField = searchsort.replace(/^\-+/, "")
, searchRev = searchsort.charAt(0) === "-"
- , sortField = sortFields[searchsort.replace(/^\-+/, "")]
+ , truncate = !npm.config.get("long")
+
+ if (Object.keys(data).length === 0) {
+ return "No match found for "+(args.map(JSON.stringify).join(" "))
+ }
- lines = Object.keys(data).map(function (d) {
+ var lines = Object.keys(data).map(function (d) {
+ // strip keyname
return data[d]
- }).map(function (data) {
- // turn a pkg data into a string
- // [name,who,desc,targets,keywords] tuple
- // also set longest to the longest name
- if (typeof data.keywords === "string") {
- data.keywords = data.keywords.split(/[,\s]+/)
+ }).map(function(dat) {
+ dat.author = dat.maintainers
+ delete dat.maintainers
+ dat.date = dat.time
+ delete dat.time
+ return dat
+ }).map(function(dat) {
+ // split keywords on whitespace or ,
+ if (typeof dat.keywords === "string") {
+ dat.keywords = dat.keywords.split(/[,\s]+/)
}
- if (!Array.isArray(data.keywords)) data.keywords = []
- var l = [ data.name
- , data.description || ""
- , data.maintainers.join(" ")
- , data.time
- , data.version || ""
- , (data.keywords || []).join(" ")
- ]
- l.forEach(function (s, i) {
- var len = s.length
- longest[i] = Math.min(maxLen[i] || Infinity
- ,Math.max(longest[i] || 0, len))
- if (len > longest[i]) {
- l._undent = l._undent || []
- l._undent[i] = len - longest[i]
- }
- l[i] = ('' + l[i]).replace(/\s+/g, " ")
- })
- return l
- }).sort(function (a, b) {
- // a and b are "line" objects of [name, desc, maint, time, kw]
+ if (Array.isArray(dat.keywords)) {
+ dat.keywords = dat.keywords.join(' ')
+ }
+
+ // split author on whitespace or ,
+ if (typeof dat.author === "string") {
+ dat.author = dat.author.split(/[,\s]+/)
+ }
+ if (Array.isArray(dat.author)) {
+ dat.author = dat.author.join(' ')
+ }
+ return dat
+ })
+
+ lines.sort(function(a, b) {
var aa = a[sortField].toLowerCase()
, bb = b[sortField].toLowerCase()
return aa === bb ? 0
- : aa < bb ? (searchRev ? 1 : -1)
- : (searchRev ? -1 : 1)
- }).map(function (line) {
- return line.map(function (s, i) {
- spaces = spaces || longest.map(function (n) {
- return new Array(n + 2).join(" ")
- })
- var len = s.length
- if (line._undent && line._undent[i - 1]) {
- len += line._undent[i - 1] - 1
- }
- return s + spaces[i].substr(len)
- }).join(" ").substr(0, cols).trim()
- }).map(function (line) {
- // colorize!
- args.forEach(function (arg, i) {
- line = addColorMarker(line, arg, i)
- })
- return colorize(line).trim()
+ : aa < bb ? -1 : 1
})
- if (lines.length === 0) {
- return "No match found for "+(args.map(JSON.stringify).join(" "))
- }
+ if (searchRev) lines.reverse()
- // build the heading padded to the longest in each field
- return headings.map(function (h, i) {
- var space = Math.max(2, 3 + (longest[i] || 0) - h.length)
- return h + (new Array(space).join(" "))
- }).join("").substr(0, cols).trim() + "\n" + lines.join("\n")
+ var columns = npm.config.get("description")
+ ? ["name", "description", "author", "date", "version", "keywords"]
+ : ["name", "author", "date", "version", "keywords"]
+
+ var output = columnify(lines, {
+ include: columns
+ , truncate: truncate
+ , config: {
+ name: { maxWidth: 40, truncate: false, truncateMarker: '' }
+ , description: { maxWidth: 60 }
+ , author: { maxWidth: 20 }
+ , date: { maxWidth: 11 }
+ , version: { maxWidth: 11 }
+ , keywords: { maxWidth: Infinity }
+ }
+ })
+ output = trimToMaxWidth(output)
+ output = highlightSearchTerms(output, args)
+ return output
}
var colors = [31, 33, 32, 36, 34, 35 ]
, cl = colors.length
+
function addColorMarker (str, arg, i) {
var m = i % cl + 1
, markStart = String.fromCharCode(m)
var uncolor = npm.color ? "\033[0m" : ""
return line.split("\u0000").join(uncolor)
}
+
+function getMaxWidth() {
+ try {
+ var tty = require("tty")
+ , stdout = process.stdout
+ , cols = !tty.isatty(stdout.fd) ? Infinity
+ : process.stdout.getWindowSize()[0]
+ cols = (cols == 0) ? Infinity : cols
+ } catch (ex) { cols = Infinity }
+ return cols
+}
+
+function trimToMaxWidth(str) {
+ var maxWidth = getMaxWidth()
+ return str.split('\n').map(function(line) {
+ return line.slice(0, maxWidth)
+ }).join('\n')
+}
+
+function highlightSearchTerms(str, terms) {
+ terms.forEach(function (arg, i) {
+ str = addColorMarker(str, arg, i)
+ })
+
+ return colorize(str).trim()
+}
process.nextTick(dequeue)
}
- var sh = "sh"
- var shFlag = "-c"
-
- if (process.platform === "win32") {
- sh = "cmd"
- shFlag = "/c"
- }
-
var conf = { cwd: wd
, env: env
, stdio: [ 0, 1, 2 ]
conf.gid = gid ^ 0
}
+ var sh = "sh"
+ var shFlag = "-c"
+
+ if (process.platform === "win32") {
+ sh = "cmd"
+ shFlag = "/c"
+ conf.windowsVerbatimArguments = true
+ }
+
var proc = spawn(sh, [shFlag, cmd], conf)
proc.on("close", function (code, signal) {
if (signal) {
.SH "SYNOPSIS"
.
.nf
-npm docs <pkgname>
+npm docs [<pkgname> [<pkgname> \.\.\.]]
npm docs (with no args in a package dir)
-npm home <pkgname>
+npm home [<pkgname> [<pkgname> \.\.\.]]
npm home (with no args in a package dir)
.
.fi
.SH "DESCRIPTION"
This command tries to guess at the likely location of a package\'s
documentation URL, and then tries to open it using the \fB\-\-browser\fR
-config param\. If no package name is provided, it will search for
-a \fBpackage\.json\fR in the current folder and use the \fBname\fR property\.
+config param\. You can pass multiple package names at once\. If no
+package name is provided, it will search for a \fBpackage\.json\fR in
+the current folder and use the \fBname\fR property\.
.
.SH "CONFIGURATION"
.
.IP "" 4
.
.nf
-npm@1.3.23 /path/to/npm
+npm@1.3.24 /path/to/npm
└─┬ init\-package\-json@0\.0\.4
└── promzard@0\.1\.5
.
.SH "SYNOPSIS"
.
.nf
-npm search [search terms \.\.\.]
+npm search [\-\-long] [search terms \.\.\.]
npm s [search terms \.\.\.]
npm se [search terms \.\.\.]
.
A trailing \fB/\fR will be ignored in this case\. (Note that many regular
expression characters must be escaped or quoted in most shells\.)
.
+.SH "CONFIGURATION"
+.
+.SS "long"
+.
+.IP "\(bu" 4
+Default: false
+.
+.IP "\(bu" 4
+Type: Boolean
+.
+.IP "" 0
+.
+.P
+Display full package descriptions and other long text across multiple
+lines\. When disabled (default) search results are truncated to fit
+neatly on a single line\. Modules with extremely long names will
+fall on multiple lines\.
+.
.SH "SEE ALSO"
.
.IP "\(bu" 4
.fi
.
.SH "VERSION"
-1.3.23
+1.3.24
.
.SH "DESCRIPTION"
npm is the package manager for the Node JavaScript platform\. It puts
.fi
.
.SH "VERSION"
-1.3.23
+1.3.24
.
.SH "DESCRIPTION"
This is the API documentation for npm\.
.IP "" 0
.
.P
-Show extended information in \fBnpm ls\fR
+Show extended information in \fBnpm ls\fR and \fBnpm search\fR\|\.
.
.SS "message"
.
--- /dev/null
+# columnify
+
+[![Build Status](https://travis-ci.org/timoxley/columnify.png?branch=master)](https://travis-ci.org/timoxley/columnify)
+
+Create text-based columns suitable for console output.
+Supports minimum and maximum column widths via truncation and text wrapping.
+
+Designed to [handle sensible wrapping in npm search results](https://github.com/isaacs/npm/pull/2328).
+
+`npm search` before & after integrating columnify:
+
+![npm-tidy-search](https://f.cloud.github.com/assets/43438/1848959/ae02ad04-76a1-11e3-8255-4781debffc26.gif)
+
+## Installation & Update
+
+```
+$ npm install --save columnify@latest
+```
+
+## Usage
+
+```js
+var columnify = require('columnify')
+var columns = columnify(data, options)
+console.log(columns)
+```
+
+## Examples
+
+### Simple Columns
+
+Text is aligned under column headings. Columns are automatically resized
+to fit the content of the largest cell. Each cell will be padded with
+spaces to fill the available space and ensure column contents are
+left-aligned.
+
+```js
+var columnify = require('columnify')
+
+var columns = columnify([{
+ name: 'mod1',
+ version: '0.0.1'
+}, {
+ name: 'module2',
+ version: '0.2.0'
+}])
+
+console.log(columns)
+```
+```
+NAME VERSION
+mod1 0.0.1
+module2 0.2.0
+```
+
+### Wrapping Column Cells
+
+You can define the maximum width before wrapping for individual cells in
+columns. Minimum width is also supported. Wrapping will happen at word
+boundaries. Empty cells or those which do not fill the max/min width
+will be padded with spaces.
+
+```js
+var columnify = require('columnify')
+
+var columns = columnify([{
+ name: 'mod1',
+ description: 'some description which happens to be far larger than the max',
+ version: '0.0.1',
+}, {
+ name: 'module-two',
+ description: 'another description larger than the max',
+ version: '0.2.0',
+})
+
+console.log(columns)
+```
+```
+NAME DESCRIPTION VERSION
+mod1 some description which happens 0.0.1
+ to be far larger than the max
+module-two another description larger 0.2.0
+ than the max
+```
+
+### Truncated Columns
+
+You can disable wrapping and instead truncate content at the maximum
+column width. Truncation respects word boundaries. A truncation marker,
+`…` will appear next to the last word in any truncated line.
+
+```js
+var columns = columnify(data, {
+ truncate: true,
+ config: {
+ description: {
+ maxWidth: 20
+ }
+ }
+})
+
+console.log(columns)
+```
+
+```
+NAME DESCRIPTION VERSION
+mod1 some description… 0.0.1
+module-two another description… 0.2.0
+```
+
+
+### Custom Truncation Marker
+
+You can change the truncation marker to something other than the default
+`…`.
+
+```js
+var columns = columnify(data, {
+ truncate: true,
+ truncateMarker: '>',
+ widths: {
+ description: {
+ maxWidth: 20
+ }
+ }
+})
+
+console.log(columns)
+```
+
+```
+NAME DESCRIPTION VERSION
+mod1 some description> 0.0.1
+module-two another description> 0.2.0
+```
+
+### Custom Column Splitter
+
+If your columns need some bling, you can split columns with custom
+characters.
+
+```js
+
+var columns = columnify(data, {
+ columnSplitter: ' | '
+})
+
+console.log(columns)
+```
+```
+NAME | DESCRIPTION | VERSION
+mod1 | some description which happens to be far larger than the max | 0.0.1
+module-two | another description larger than the max | 0.2.0
+```
+
+### Filtering & Ordering Columns
+
+By default, all properties are converted into columns, whether or not
+they exist on every object or not.
+
+To explicitly specify which columns to include, and in which order,
+supply an "include" array:
+
+```js
+var data = [{
+ name: 'module1',
+ description: 'some description',
+ version: '0.0.1',
+}, {
+ name: 'module2',
+ description: 'another description',
+ version: '0.2.0',
+}]
+
+var columns = columnify(data, {
+ include: ['name', 'version'] // note description not included
+})
+
+console.log(columns)
+```
+
+```
+NAME VERSION
+module1 0.0.1
+module2 0.2.0
+```
+## License
+
+MIT
--- /dev/null
+"use strict"
+
+var utils = require('./utils')
+var padRight = utils.padRight
+var splitIntoLines = utils.splitIntoLines
+var splitLongWords = utils.splitLongWords
+
+var DEFAULTS = {
+ maxWidth: Infinity,
+ minWidth: 0,
+ columnSplitter: ' ',
+ truncate: false,
+ truncateMarker: '…',
+ headingTransform: function(key) {
+ return key.toUpperCase()
+ },
+ dataTransform: function(cell, column, index) {
+ return cell
+ }
+}
+
+module.exports = function(items, options) {
+
+ options = options || {}
+
+ var columnConfigs = options.config || {}
+ delete options.config // remove config so doesn't appear on every column.
+
+ // Option defaults inheritance:
+ // options.config[columnName] => options => DEFAULTS
+ options = mixin(options, DEFAULTS)
+ options.config = options.config || Object.create(null)
+
+ options.spacing = options.spacing || '\n' // probably useless
+
+ var columnNames = options.include || [] // optional user-supplied columns to include
+
+ // if not suppled column names, automatically determine columns from data keys
+ if (!columnNames.length) {
+ items.forEach(function(item) {
+ for (var columnName in item) {
+ if (columnNames.indexOf(columnName) === -1) columnNames.push(columnName)
+ }
+ })
+ }
+
+ // initialize column defaults (each column inherits from options.config)
+ var columns = columnNames.reduce(function(columns, columnName) {
+ var column = Object.create(options)
+ columns[columnName] = mixin(column, columnConfigs[columnName])
+ return columns
+ }, Object.create(null))
+
+ // sanitize column settings
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ column.maxWidth = Math.ceil(column.maxWidth)
+ column.minWidth = Math.ceil(column.minWidth)
+ column.truncate = !!column.truncate
+ })
+
+ // sanitize data
+ items = items.map(function(item) {
+ var result = Object.create(null)
+ columnNames.forEach(function(columnName) {
+ // null/undefined -> ''
+ result[columnName] = item[columnName] != null ? item[columnName] : ''
+ // toString everything
+ result[columnName] = '' + result[columnName]
+ // remove funky chars
+ result[columnName] = result[columnName].replace(/\s+/g, " ")
+ })
+ return result
+ })
+
+ // transform data cells
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ items = items.map(function(item, index) {
+ item[columnName] = column.dataTransform(item[columnName], column, index)
+ return item
+ })
+ })
+
+ // add headers
+ var headers = {}
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ headers[columnName] = column.headingTransform(columnName)
+ })
+ items.unshift(headers)
+
+ // get actual max-width between min & max
+ // based on length of data in columns
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ column.width = items.map(function(item) {
+ return item[columnName]
+ }).reduce(function(min, cur) {
+ return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, cur.length)))
+ }, 0)
+ })
+
+ // split long words so they can break onto multiple lines
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ items = items.map(function(item) {
+ item[columnName] = splitLongWords(item[columnName], column.width, column.truncateMarker)
+ return item
+ })
+ })
+
+ // wrap long lines. each item is now an array of lines.
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ items = items.map(function(item, index) {
+ var cell = item[columnName]
+ item[columnName] = splitIntoLines(cell, column.width)
+
+ // if truncating required, only include first line + add truncation char
+ if (column.truncate && item[columnName].length > 1) {
+ item[columnName] = splitIntoLines(cell, column.width - column.truncateMarker.length)
+ var firstLine = item[columnName][0]
+ if (!endsWith(firstLine, column.truncateMarker)) item[columnName][0] += column.truncateMarker
+ item[columnName] = item[columnName].slice(0, 1)
+ }
+ return item
+ })
+ })
+
+ // recalculate column widths from truncated output/lines
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ column.width = items.map(function(item) {
+ return item[columnName].reduce(function(min, cur) {
+ return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, cur.length)))
+ }, 0)
+ }).reduce(function(min, cur) {
+ return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, cur)))
+ }, 0)
+ })
+
+ var rows = createRows(items, columns, columnNames) // merge lines into rows
+
+ // conceive output
+ return rows.reduce(function(output, row) {
+ return output.concat(row.reduce(function(rowOut, line) {
+ return rowOut.concat(line.join(options.columnSplitter))
+ }, []))
+ }, []).join(options.spacing)
+}
+
+/**
+ * Convert wrapped lines into rows with padded values.
+ *
+ * @param Array items data to process
+ * @param Array columns column width settings for wrapping
+ * @param Array columnNames column ordering
+ * @return Array items wrapped in arrays, corresponding to lines
+ */
+
+function createRows(items, columns, columnNames) {
+ return items.map(function(item) {
+ var row = []
+ var numLines = 0
+ columnNames.forEach(function(columnName) {
+ numLines = Math.max(numLines, item[columnName].length)
+ })
+ // combine matching lines of each rows
+ for (var i = 0; i < numLines; i++) {
+ row[i] = row[i] || []
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ var val = item[columnName][i] || '' // || '' ensures empty columns get padded
+ row[i].push(padRight(val, column.width))
+ })
+ }
+ return row
+ })
+}
+
+/**
+ * Generic source->target mixin.
+ * Copy properties from `source` into `target` if target doesn't have them.
+ * Destructive. Modifies `target`.
+ *
+ * @param target Object target for mixin properties.
+ * @param source Object source of mixin properties.
+ * @return Object `target` after mixin applied.
+ */
+
+function mixin(target, source) {
+ source = source || {}
+ for (var key in source) {
+ if (target.hasOwnProperty(key)) continue
+ target[key] = source[key]
+ }
+ return target
+}
+
+/**
+ * Adapted from String.prototype.endsWith polyfill.
+ */
+
+function endsWith(target, searchString, position) {
+ position = position || target.length;
+ position = position - searchString.length;
+ var lastIndex = target.lastIndexOf(searchString);
+ return lastIndex !== -1 && lastIndex === position;
+}
--- /dev/null
+{
+ "name": "columnify",
+ "version": "0.1.2",
+ "description": "Render data in text columns, supports in-column text-wrap.",
+ "main": "index.js",
+ "scripts": {
+ "test": "tap test"
+ },
+ "author": {
+ "name": "Tim Oxley"
+ },
+ "license": "MIT",
+ "devDependencies": {
+ "tape": "~2.3.0",
+ "tap": "~0.4.6"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/timoxley/columnify.git"
+ },
+ "keywords": [
+ "column",
+ "text",
+ "ansi",
+ "console",
+ "terminal",
+ "wrap",
+ "table"
+ ],
+ "bugs": {
+ "url": "https://github.com/timoxley/columnify/issues"
+ },
+ "homepage": "https://github.com/timoxley/columnify",
+ "readme": "# columnify\n\n[![Build Status](https://travis-ci.org/timoxley/columnify.png?branch=master)](https://travis-ci.org/timoxley/columnify)\n\nCreate text-based columns suitable for console output. \nSupports minimum and maximum column widths via truncation and text wrapping.\n\nDesigned to [handle sensible wrapping in npm search results](https://github.com/isaacs/npm/pull/2328).\n\n`npm search` before & after integrating columnify:\n\n![npm-tidy-search](https://f.cloud.github.com/assets/43438/1848959/ae02ad04-76a1-11e3-8255-4781debffc26.gif)\n\n## Installation & Update\n\n```\n$ npm install --save columnify@latest\n```\n\n## Usage\n\n```js\nvar columnify = require('columnify')\nvar columns = columnify(data, options)\nconsole.log(columns)\n```\n\n## Examples\n\n### Simple Columns\n\nText is aligned under column headings. Columns are automatically resized\nto fit the content of the largest cell. Each cell will be padded with\nspaces to fill the available space and ensure column contents are\nleft-aligned.\n\n```js\nvar columnify = require('columnify')\n\nvar columns = columnify([{\n name: 'mod1',\n version: '0.0.1'\n}, {\n name: 'module2',\n version: '0.2.0'\n}])\n\nconsole.log(columns)\n```\n```\nNAME VERSION\nmod1 0.0.1 \nmodule2 0.2.0 \n```\n\n### Wrapping Column Cells\n\nYou can define the maximum width before wrapping for individual cells in\ncolumns. Minimum width is also supported. Wrapping will happen at word\nboundaries. Empty cells or those which do not fill the max/min width\nwill be padded with spaces.\n\n```js\nvar columnify = require('columnify')\n\nvar columns = columnify([{\n name: 'mod1',\n description: 'some description which happens to be far larger than the max',\n version: '0.0.1',\n}, {\n name: 'module-two',\n description: 'another description larger than the max',\n version: '0.2.0',\n})\n\nconsole.log(columns)\n```\n```\nNAME DESCRIPTION VERSION\nmod1 some description which happens 0.0.1\n to be far larger than the max\nmodule-two another description larger 0.2.0\n than the max\n```\n\n### Truncated Columns\n\nYou can disable wrapping and instead truncate content at the maximum\ncolumn width. Truncation respects word boundaries. A truncation marker,\n`…` will appear next to the last word in any truncated line.\n\n```js\nvar columns = columnify(data, {\n truncate: true,\n config: {\n description: {\n maxWidth: 20\n }\n }\n})\n\nconsole.log(columns)\n```\n\n```\nNAME DESCRIPTION VERSION\nmod1 some description… 0.0.1 \nmodule-two another description… 0.2.0 \n```\n\n\n### Custom Truncation Marker\n\nYou can change the truncation marker to something other than the default\n`…`.\n\n```js\nvar columns = columnify(data, {\n truncate: true,\n truncateMarker: '>',\n widths: {\n description: {\n maxWidth: 20\n }\n }\n})\n\nconsole.log(columns)\n```\n\n```\nNAME DESCRIPTION VERSION\nmod1 some description> 0.0.1 \nmodule-two another description> 0.2.0 \n```\n\n### Custom Column Splitter\n\nIf your columns need some bling, you can split columns with custom\ncharacters.\n\n```js\n\nvar columns = columnify(data, {\n columnSplitter: ' | '\n})\n\nconsole.log(columns)\n```\n```\nNAME | DESCRIPTION | VERSION\nmod1 | some description which happens to be far larger than the max | 0.0.1\nmodule-two | another description larger than the max | 0.2.0\n```\n\n### Filtering & Ordering Columns\n\nBy default, all properties are converted into columns, whether or not\nthey exist on every object or not.\n\nTo explicitly specify which columns to include, and in which order,\nsupply an \"include\" array:\n\n```js\nvar data = [{\n name: 'module1',\n description: 'some description',\n version: '0.0.1',\n}, {\n name: 'module2',\n description: 'another description',\n version: '0.2.0',\n}]\n\nvar columns = columnify(data, {\n include: ['name', 'version'] // note description not included\n})\n\nconsole.log(columns)\n```\n\n```\nNAME VERSION\nmodule1 0.0.1\nmodule2 0.2.0\n```\n## License\n\nMIT\n",
+ "readmeFilename": "Readme.md",
+ "_id": "columnify@0.1.2",
+ "dist": {
+ "shasum": "ab1a1f1e37b26ba4b87c6920fb717fe51c827042"
+ },
+ "_from": "columnify@0.1.2",
+ "_resolved": "https://registry.npmjs.org/columnify/-/columnify-0.1.2.tgz"
+}
--- /dev/null
+/**
+ * Pad `str` up to total length `max` with `chr`.
+ * If `str` is longer than `max`, padRight will return `str` unaltered.
+ *
+ * @param String str string to pad
+ * @param Number max total length of output string
+ * @param String chr optional. Character to pad with. default: ' '
+ * @return String padded str
+ */
+
+function padRight(str, max, chr) {
+ str = str != null ? str : ''
+ str = String(str)
+ var length = 1 + max - str.length
+ if (length <= 0) return str
+ return str + Array.apply(null, {length: length})
+ .join(chr || ' ')
+}
+
+/**
+ * Split a String `str` into lines of maxiumum length `max`.
+ * Splits on word boundaries.
+ *
+ * @param String str string to split
+ * @param Number max length of each line
+ * @return Array Array containing lines.
+ */
+
+function splitIntoLines(str, max) {
+ return str.trim().split(' ').reduce(function(lines, word) {
+ var line = lines[lines.length - 1]
+ if (line && line.join(' ').length + word.length < max) {
+ lines[lines.length - 1].push(word) // add to line
+ }
+ else lines.push([word]) // new line
+ return lines
+ }, []).map(function(l) {
+ return l.join(' ')
+ })
+}
+
+/**
+ * Add spaces and `truncationChar` between words of
+ * `str` which are longer than `max`.
+ *
+ * @param String str string to split
+ * @param Number max length of each line
+ * @param Number truncationChar character to append to split words
+ * @return String
+ */
+
+function splitLongWords(str, max, truncationChar, result) {
+ str = str.trim()
+ result = result || []
+ if (!str) return result.join(' ') || ''
+ var words = str.split(' ')
+ var word = words.shift() || str
+
+ if (word.length > max) {
+ var remainder = word.slice(max - truncationChar.length) // get remainder
+ words.unshift(remainder) // save remainder for next loop
+
+ word = word.slice(0, max - truncationChar.length) // grab truncated word
+ word += truncationChar // add trailing … or whatever
+ }
+ result.push(word)
+ return splitLongWords(words.join(' '), max, truncationChar, result)
+}
+
+/**
+ * Exports
+ */
+
+module.exports.padRight = padRight
+module.exports.splitIntoLines = splitIntoLines
+module.exports.splitLongWords = splitLongWords
--- /dev/null
+The ISC License
+
+Copyright (c) Isaac Z. Schlueter
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
},
"name": "promzard",
"description": "prompting wizardly",
- "version": "0.2.0",
+ "version": "0.2.1",
"repository": {
"url": "git://github.com/isaacs/promzard"
},
"scripts": {
"test": "tap test/*.js"
},
+ "license": "ISC",
"readme": "# promzard\n\nA prompting wizard for building files from specialized PromZard modules.\nUsed by `npm init`.\n\nA reimplementation of @SubStack's\n[prompter](https://github.com/substack/node-prompter), which does not\nuse AST traversal.\n\nFrom another point of view, it's a reimplementation of\n[@Marak](https://github.com/marak)'s\n[wizard](https://github.com/Marak/wizard) which doesn't use schemas.\n\nThe goal is a nice drop-in enhancement for `npm init`.\n\n## Usage\n\n```javascript\nvar promzard = require('promzard')\npromzard(inputFile, optionalContextAdditions, function (er, data) {\n // .. you know what you doing ..\n})\n```\n\nIn the `inputFile` you can have something like this:\n\n```javascript\nvar fs = require('fs')\nmodule.exports = {\n \"greeting\": prompt(\"Who shall you greet?\", \"world\", function (who) {\n return \"Hello, \" + who\n }),\n \"filename\": __filename,\n \"directory\": function (cb) {\n fs.readdir(__dirname, cb)\n }\n}\n```\n\nWhen run, promzard will display the prompts and resolve the async\nfunctions in order, and then either give you an error, or the resolved\ndata, ready to be dropped into a JSON file or some other place.\n\n\n### promzard(inputFile, ctx, callback)\n\nThe inputFile is just a node module. You can require() things, set\nmodule.exports, etc. Whatever that module exports is the result, and it\nis walked over to call any functions as described below.\n\nThe only caveat is that you must give PromZard the full absolute path\nto the module (you can get this via Node's `require.resolve`.) Also,\nthe `prompt` function is injected into the context object, so watch out.\n\nWhatever you put in that `ctx` will of course also be available in the\nmodule. You can get quite fancy with this, passing in existing configs\nand so on.\n\n### Class: promzard.PromZard(file, ctx)\n\nJust like the `promzard` function, but the EventEmitter that makes it\nall happen. Emits either a `data` event with the data, or a `error`\nevent if it blows up.\n\nIf `error` is emitted, then `data` never will be.\n\n### prompt(...)\n\nIn the promzard input module, you can call the `prompt` function.\nThis prompts the user to input some data. The arguments are interpreted\nbased on type:\n\n1. `string` The first string encountered is the prompt. The second is\n the default value.\n2. `function` A transformer function which receives the data and returns\n something else. More than meets the eye.\n3. `object` The `prompt` member is the prompt, the `default` member is\n the default value, and the `transform` is the transformer.\n\nWhatever the final value is, that's what will be put on the resulting\nobject.\n\n### Functions\n\nIf there are any functions on the promzard input module's exports, then\npromzard will call each of them with a callback. This way, your module\ncan do asynchronous actions if necessary to validate or ascertain\nwhatever needs verification.\n\nThe functions are called in the context of the ctx object, and are given\na single argument, which is a callback that should be called with either\nan error, or the result to assign to that spot.\n\nIn the async function, you can also call prompt() and return the result\nof the prompt in the callback.\n\nFor example, this works fine in a promzard module:\n\n```\nexports.asyncPrompt = function (cb) {\n fs.stat(someFile, function (er, st) {\n // if there's an error, no prompt, just error\n // otherwise prompt and use the actual file size as the default\n cb(er, prompt('file size', st.size))\n })\n}\n```\n\nYou can also return other async functions in the async function\ncallback. Though that's a bit silly, it could be a handy way to reuse\nfunctionality in some cases.\n\n### Sync vs Async\n\nThe `prompt()` function is not synchronous, though it appears that way.\nIt just returns a token that is swapped out when the data object is\nwalked over asynchronously later, and returns a token.\n\nFor that reason, prompt() calls whose results don't end up on the data\nobject are never shown to the user. For example, this will only prompt\nonce:\n\n```\nexports.promptThreeTimes = prompt('prompt me once', 'shame on you')\nexports.promptThreeTimes = prompt('prompt me twice', 'um....')\nexports.promptThreeTimes = prompt('you cant prompt me again')\n```\n\n### Isn't this exactly the sort of 'looks sync' that you said was bad about other libraries?\n\nYeah, sorta. I wouldn't use promzard for anything more complicated than\na wizard that spits out prompts to set up a config file or something.\nMaybe there are other use cases I haven't considered.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/isaacs/promzard/issues"
},
"homepage": "https://github.com/isaacs/promzard",
- "_id": "promzard@0.2.0",
+ "_id": "promzard@0.2.1",
"_from": "promzard@~0.2.0"
}
return out.rstrip('\n')
def _GetSdkVersionInfoItem(self, sdk, infoitem):
- return self._GetStdout(['xcodebuild', '-version', '-sdk', sdk, infoitem])
+ # xcodebuild requires Xcode and can't run on Command Line Tools-only
+ # systems from 10.7 onward.
+ # Since the CLT has no SDK paths anyway, returning None is the
+ # most sensible route and should still do the right thing.
+ try:
+ return self._GetStdout(['xcodebuild', '-version', '-sdk', sdk, infoitem])
+ except:
+ pass
def _SdkRoot(self, configname):
if configname is None:
cflags += self._Settings().get('WARNING_CFLAGS', [])
- config = self.spec['configurations'][self.configname]
- framework_dirs = config.get('mac_framework_dirs', [])
- for directory in framework_dirs:
- cflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
+ if 'SDKROOT' in self._Settings():
+ config = self.spec['configurations'][self.configname]
+ framework_dirs = config.get('mac_framework_dirs', [])
+ for directory in framework_dirs:
+ cflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
self.configname = None
return cflags
for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []):
ldflags.append('-Wl,-rpath,' + rpath)
- config = self.spec['configurations'][self.configname]
- framework_dirs = config.get('mac_framework_dirs', [])
- for directory in framework_dirs:
- ldflags.append('-F' + directory.replace('$(SDKROOT)', self._SdkPath()))
+ if 'SDKROOT' in self._Settings():
+ config = self.spec['configurations'][self.configname]
+ framework_dirs = config.get('mac_framework_dirs', [])
+ for directory in framework_dirs:
+ ldflags.append('-F' + directory.replace('$(SDKROOT)', self._SdkPath()))
self.configname = None
return ldflags
l = '-l' + m.group(1)
else:
l = library
- return l.replace('$(SDKROOT)', self._SdkPath(config_name))
+ if self._SdkPath():
+ return l.replace('$(SDKROOT)', self._SdkPath(config_name))
+ else:
+ return l
def AdjustLibraries(self, libraries, config_name=None):
"""Transforms entries like 'Cocoa.framework' in libraries into entries like
"bindings",
"gyp"
],
- "version": "0.12.1",
+ "version": "0.12.2",
"installVersion": 9,
"author": {
"name": "Nathan Rajlich",
"url": "https://github.com/TooTallNate/node-gyp/issues"
},
"homepage": "https://github.com/TooTallNate/node-gyp",
- "_id": "node-gyp@0.12.1",
- "dist": {
- "shasum": "edc233dc9bbbd567cb167adf96c31a245c2712a4"
- },
- "_from": "node-gyp@latest",
- "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-0.12.1.tgz"
+ "_id": "node-gyp@0.12.2",
+ "_from": "node-gyp@latest"
}
this.log.warn("adduser", "Incorrect username or password\n"
+"You can reset your account by visiting:\n"
+"\n"
- +" http://admin.npmjs.org/reset\n")
+ +" https://npmjs.org/forgot\n")
}
return cb(error)
},
"homepage": "https://github.com/isaacs/couch-login",
"_id": "couch-login@0.1.19",
- "_from": "couch-login@~0.1.18"
+ "dist": {
+ "shasum": "5c472f64670dfb43fc381d290629b223edb64afa"
+ },
+ "_from": "couch-login@~0.1.18",
+ "_resolved": "https://registry.npmjs.org/couch-login/-/couch-login-0.1.19.tgz"
}
},
"name": "npm-registry-client",
"description": "Client for the npm registry",
- "version": "0.3.2",
+ "version": "0.3.3",
"repository": {
"url": "git://github.com/isaacs/npm-registry-client"
},
"url": "https://github.com/isaacs/npm-registry-client/issues"
},
"homepage": "https://github.com/isaacs/npm-registry-client",
- "_id": "npm-registry-client@0.3.2",
- "_from": "npm-registry-client@~0.3.1"
+ "_id": "npm-registry-client@0.3.3",
+ "dist": {
+ "shasum": "da08bb681fb24aa5c988ca71f8c10f27f09daf4a"
+ },
+ "_from": "npm-registry-client@~0.3.2",
+ "_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-0.3.3.tgz"
}
, "bin-links" : true
, browser : null
- , ca: // the npm CA certificate.
- [ "-----BEGIN CERTIFICATE-----\n"+
- "MIIChzCCAfACCQDauvz/KHp8ejANBgkqhkiG9w0BAQUFADCBhzELMAkGA1UEBhMC\n"+
- "VVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMQwwCgYDVQQKEwNucG0x\n"+
- "IjAgBgNVBAsTGW5wbSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxDjAMBgNVBAMTBW5w\n"+
- "bUNBMRcwFQYJKoZIhvcNAQkBFghpQGl6cy5tZTAeFw0xMTA5MDUwMTQ3MTdaFw0y\n"+
- "MTA5MDIwMTQ3MTdaMIGHMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNV\n"+
- "BAcTB09ha2xhbmQxDDAKBgNVBAoTA25wbTEiMCAGA1UECxMZbnBtIENlcnRpZmlj\n"+
- "YXRlIEF1dGhvcml0eTEOMAwGA1UEAxMFbnBtQ0ExFzAVBgkqhkiG9w0BCQEWCGlA\n"+
- "aXpzLm1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLI4tIqPpRW+ACw9GE\n"+
- "OgBlJZwK5f8nnKCLK629Pv5yJpQKs3DENExAyOgDcyaF0HD0zk8zTp+ZsLaNdKOz\n"+
- "Gn2U181KGprGKAXP6DU6ByOJDWmTlY6+Ad1laYT0m64fERSpHw/hjD3D+iX4aMOl\n"+
- "y0HdbT5m1ZGh6SJz3ZqxavhHLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAC4ySDbC\n"+
- "l7W1WpLmtLGEQ/yuMLUf6Jy/vr+CRp4h+UzL+IQpCv8FfxsYE7dhf/bmWTEupBkv\n"+
- "yNL18lipt2jSvR3v6oAHAReotvdjqhxddpe5Holns6EQd1/xEZ7sB1YhQKJtvUrl\n"+
- "ZNufy1Jf1r0ldEGeA+0ISck7s+xSh9rQD2Op\n"+
- "-----END CERTIFICATE-----\n",
-
- // "GlobalSign Root CA"
- "-----BEGIN CERTIFICATE-----\n"+
- "MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx\n"+
- "GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds\n"+
- "b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV\n"+
- "BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD\n"+
- "VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa\n"+
- "DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc\n"+
- "THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb\n"+
- "Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP\n"+
- "c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX\n"+
- "gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n"+
- "HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF\n"+
- "AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj\n"+
- "Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG\n"+
- "j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH\n"+
- "hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC\n"+
- "X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\n"+
- "-----END CERTIFICATE-----\n",
-
- // "GlobalSign Root CA - R2"
- "-----BEGIN CERTIFICATE-----\n"+
- "MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv\n"+
- "YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh\n"+
- "bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT\n"+
- "aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln\n"+
- "bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6\n"+
- "ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp\n"+
- "s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN\n"+
- "S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL\n"+
- "TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C\n"+
- "ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E\n"+
- "FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i\n"+
- "YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN\n"+
- "BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp\n"+
- "9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu\n"+
- "01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7\n"+
- "9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7\n"+
- "TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==\n"+
- "-----END CERTIFICATE-----\n",
-
- // GlobalSign Organization Validation CA - G2
- "-----BEGIN CERTIFICATE-----\n"+
- "MIIEYDCCA0igAwIBAgILBAAAAAABL07hRQwwDQYJKoZIhvcNAQEFBQAwVzELMAkG\n"+
- "A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv\n"+
- "b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw0xMTA0MTMxMDAw\n"+
- "MDBaFw0yMjA0MTMxMDAwMDBaMF0xCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i\n"+
- "YWxTaWduIG52LXNhMTMwMQYDVQQDEypHbG9iYWxTaWduIE9yZ2FuaXphdGlvbiBW\n"+
- "YWxpZGF0aW9uIENBIC0gRzIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n"+
- "AQDdNR3yIFQmGtDvpW+Bdllw3Of01AMkHyQOnSKf1Ccyeit87ovjYWI4F6+0S3qf\n"+
- "ZyEcLZVUunm6tsTyDSF0F2d04rFkCJlgePtnwkv3J41vNnbPMYzl8QbX3FcOW6zu\n"+
- "zi2rqqlwLwKGyLHQCAeV6irs0Z7kNlw7pja1Q4ur944+ABv/hVlrYgGNguhKujiz\n"+
- "4MP0bRmn6gXdhGfCZsckAnNate6kGdn8AM62pI3ffr1fsjqdhDFPyGMM5NgNUqN+\n"+
- "ARvUZ6UYKOsBp4I82Y4d5UcNuotZFKMfH0vq4idGhs6dOcRmQafiFSNrVkfB7cVT\n"+
- "5NSAH2v6gEaYsgmmD5W+ZoiTAgMBAAGjggElMIIBITAOBgNVHQ8BAf8EBAMCAQYw\n"+
- "EgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQUXUayjcRLdBy77fVztjq3OI91\n"+
- "nn4wRwYDVR0gBEAwPjA8BgRVHSAAMDQwMgYIKwYBBQUHAgEWJmh0dHBzOi8vd3d3\n"+
- "Lmdsb2JhbHNpZ24uY29tL3JlcG9zaXRvcnkvMDMGA1UdHwQsMCowKKAmoCSGImh0\n"+
- "dHA6Ly9jcmwuZ2xvYmFsc2lnbi5uZXQvcm9vdC5jcmwwPQYIKwYBBQUHAQEEMTAv\n"+
- "MC0GCCsGAQUFBzABhiFodHRwOi8vb2NzcC5nbG9iYWxzaWduLmNvbS9yb290cjEw\n"+
- "HwYDVR0jBBgwFoAUYHtmGkUNl8qJUC99BM00qP/8/UswDQYJKoZIhvcNAQEFBQAD\n"+
- "ggEBABvgiADHBREc/6stSEJSzSBo53xBjcEnxSxZZ6CaNduzUKcbYumlO/q2IQen\n"+
- "fPMOK25+Lk2TnLryhj5jiBDYW2FQEtuHrhm70t8ylgCoXtwtI7yw07VKoI5lkS/Z\n"+
- "9oL2dLLffCbvGSuXL+Ch7rkXIkg/pfcNYNUNUUflWP63n41edTzGQfDPgVRJEcYX\n"+
- "pOBWYdw9P91nbHZF2krqrhqkYE/Ho9aqp9nNgSvBZnWygI/1h01fwlr1kMbawb30\n"+
- "hag8IyrhFHvBN91i0ZJsumB9iOQct+R2UTjEqUdOqCsukNK1OFHrwZyKarXMsh3o\n"+
- "wFZUTKiL8IkyhtyTMr5NGvo1dbU=\n"+
- "-----END CERTIFICATE-----\n"
- ]
-
+ , ca: null
, cache : cache
, description : true
, dev : false
, editor : osenv.editor()
- , email: null
+ , email: ""
, "engine-strict": false
, force : false
{
"name": "npmconf",
- "version": "0.1.9",
+ "version": "0.1.12",
"description": "The config thing npm uses",
"main": "npmconf.js",
"directories": {
"url": "https://github.com/isaacs/npmconf/issues"
},
"homepage": "https://github.com/isaacs/npmconf",
- "_id": "npmconf@0.1.9",
- "_from": "npmconf@~0.1.7"
+ "_id": "npmconf@0.1.12",
+ "_from": "npmconf@0.1.12"
}
,"devDepenencies": "devDependencies"
,"devdependencies": "devDependencies"
,"repostitory": "repository"
+ ,"repo": "repository"
,"prefereGlobal": "preferGlobal"
,"hompage": "homepage"
,"hampage": "homepage"
{
"name": "normalize-package-data",
- "version": "0.2.7",
+ "version": "0.2.8",
"author": {
"name": "Meryn Stol",
"email": "merynstol@gmail.com"
"url": "https://github.com/meryn/normalize-package-data/issues"
},
"homepage": "https://github.com/meryn/normalize-package-data",
- "_id": "normalize-package-data@0.2.7",
+ "_id": "normalize-package-data@0.2.8",
"_from": "normalize-package-data@~0.2.7"
}
'devDepenencies should probably be devDependencies.',
'devdependencies should probably be devDependencies.',
'repostitory should probably be repository.',
+ 'repo should probably be repository.',
'prefereGlobal should probably be preferGlobal.',
'hompage should probably be homepage.',
'hampage should probably be homepage.',
,"devDepenencies": "devDependencies"
,"devdependencies": "devDependencies"
,"repostitory": "repository"
+ ,"repo": "repository"
,"prefereGlobal": "preferGlobal"
,"hompage": "homepage"
,"hampage": "homepage"
{
"name": "read-package-json",
- "version": "1.1.4",
+ "version": "1.1.6",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "https://github.com/isaacs/read-package-json/issues"
},
"homepage": "https://github.com/isaacs/read-package-json",
- "_id": "read-package-json@1.1.4",
- "_from": "read-package-json@latest"
+ "_id": "read-package-json@1.1.6",
+ "dist": {
+ "shasum": "a851dbbaca48ff78a87f890f0a9fdf43b1759d5a"
+ },
+ "_from": "read-package-json@1.1.6",
+ "_resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-1.1.6.tgz"
}
readJson.extraSet = [
gypfile,
serverjs,
+ scriptpath,
authors,
readme,
mans,
else if (typeof arguments[i] === 'function')
log = arguments[i]
}
+ if (!log) log = function () {};
cb = arguments[i]
var set = readJson.extraSet
var n = set.length
}
}
+function scriptpath (file, data, cb) {
+ if (!data.scripts) return cb(null, data);
+ var k = Object.keys(data.scripts)
+ k.forEach(scriptpath_, data.scripts)
+ cb(null, data);
+}
+function scriptpath_(key) {
+ s = this[key]
+ // This is never allowed, and only causes problems
+ if (typeof s !== 'string')
+ return delete this[key]
+ var spre = /^(\.[\/\\])?node_modules[\/\\].bin[\\\/]/
+ if (s.match(spre))
+ this[key] = this[key].replace(spre, '')
+}
+
function gypfile (file, data, cb) {
var dir = path.dirname(file)
var s = data.scripts || {}
}
function makePackageId (data) {
- return cleanString(data.name) + "@" + cleanString(data.version)
+ var name = cleanString(data.name)
+ var ver = cleanString(data.version)
+ return name + "@" + ver
}
-
function cleanString(str) {
return (!str || typeof(str) !== "string") ? "" : str.trim()
}
},
"main": "read-json.js",
"scripts": {
- "test": "tap test/*.js"
+ "test": "./node_modules/.bin/tap test/*.js"
},
"dependencies": {
"glob": "~3.1.9",
npmlog: '0',
'graceful-fs': '~1.1.8' },
devDependencies: { tap: '~0.2.5' },
- optionalDependencies: { npmlog: '0', 'graceful-fs': '~1.1.8' },
+ homepage: "https://github.com/isaacs/read-package-json",
+ optionalDependencies: { npmlog: '0', 'graceful-fs': '~1.1.8' },
_id: 'read-package-json@0.1.1',
readme: 'ERROR: No README data found!' }
{
"name": "rimraf",
- "version": "2.2.5",
+ "version": "2.2.6",
"main": "rimraf.js",
"description": "A deep deletion module for node (like `rm -rf`)",
"author": {
"url": "https://github.com/isaacs/rimraf/issues"
},
"homepage": "https://github.com/isaacs/rimraf",
- "_id": "rimraf@2.2.5",
- "_from": "rimraf@latest"
+ "_id": "rimraf@2.2.6",
+ "_from": "rimraf@~2.2.5"
}
// if we guessed wrong, and it's not a directory, then
// raise the original error.
fs.rmdir(p, function (er) {
- if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST"))
+ if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
rmkids(p, cb)
else if (er && er.code === "ENOTDIR")
cb(originalEr)
return
if (er.code === "ENOTDIR")
throw originalEr
- if (er.code === "ENOTEMPTY" || er.code === "EEXIST")
+ if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
rmkidsSync(p)
}
}
--- /dev/null
+build/
+test/
+examples/
+fs.js
+zlib.js
\ No newline at end of file
+++ /dev/null
-var Transform = require('../transform');
-var inherits = require('util').inherits;
-
-// subclass
-function MyStream () {
- Transform.call(this, {
- lowWaterMark: 0,
- encoding: 'utf8'
- });
-}
-inherits(MyStream, Transform);
-
-MyStream.prototype._transform = function (chunk, outputFn, callback) {
- outputFn(new Buffer(String(chunk).toUpperCase()));
- callback();
-};
-
-// use it!
-var s = new MyStream();
-process.stdin.resume();
-process.stdin.pipe(s).pipe(process.stdout);
-if (process.stdin.setRawMode)
- process.stdin.setRawMode(true);
-process.stdin.on('data', function (c) {
- c = c.toString();
- if (c === '\u0003' || c === '\u0004') {
- process.stdin.pause();
- s.end();
- }
- if (c === '\r')
- process.stdout.write('\n');
-});
+++ /dev/null
-var fs = require('fs');
-var FSReadable = require('../fs.js');
-var rst = new FSReadable(__filename);
-
-rst.on('end', function() {
- process.stdin.pause();
-});
-
-process.stdin.setRawMode(true);
-process.stdin.on('data', function() {
- var c = rst.read(3);
- if (!c) return;
- process.stdout.write(c);
-});
-process.stdin.resume();
+++ /dev/null
-var fs = require('fs');
-var fst = fs.createReadStream(__filename);
-var Readable = require('../readable.js');
-var rst = new Readable();
-rst.wrap(fst);
-
-rst.on('end', function() {
- process.stdin.pause();
-});
-
-process.stdin.setRawMode(true);
-process.stdin.on('data', function() {
- var c = rst.read(3);
- if (!c) return setTimeout(process.exit, 500)
- process.stdout.write(c);
-});
-process.stdin.resume();
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-// Maintainers, keep in mind that octal literals are not allowed
-// in strict mode. Use the decimal value and add a comment with
-// the octal value. Example:
-//
-// var mode = 438; /* mode=0666 */
-
-var util = require('util');
-var pathModule = require('path');
-
-var binding = process.binding('fs');
-var constants = process.binding('constants');
-var fs = exports;
-var Stream = require('stream').Stream;
-var EventEmitter = require('events').EventEmitter;
-
-var Readable = require('./lib/_stream_readable.js');
-var Writable = require('./lib/_stream_writable.js');
-
-var kMinPoolSpace = 128;
-var kPoolSize = 40 * 1024;
-
-var O_APPEND = constants.O_APPEND || 0;
-var O_CREAT = constants.O_CREAT || 0;
-var O_DIRECTORY = constants.O_DIRECTORY || 0;
-var O_EXCL = constants.O_EXCL || 0;
-var O_NOCTTY = constants.O_NOCTTY || 0;
-var O_NOFOLLOW = constants.O_NOFOLLOW || 0;
-var O_RDONLY = constants.O_RDONLY || 0;
-var O_RDWR = constants.O_RDWR || 0;
-var O_SYMLINK = constants.O_SYMLINK || 0;
-var O_SYNC = constants.O_SYNC || 0;
-var O_TRUNC = constants.O_TRUNC || 0;
-var O_WRONLY = constants.O_WRONLY || 0;
-
-var isWindows = process.platform === 'win32';
-
-var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
-
-function rethrow() {
- // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
- // is fairly slow to generate.
- if (DEBUG) {
- var backtrace = new Error;
- return function(err) {
- if (err) {
- backtrace.message = err.message;
- err = backtrace;
- throw err;
- }
- };
- }
-
- return function(err) {
- if (err) {
- throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
- }
- };
-}
-
-function maybeCallback(cb) {
- return typeof cb === 'function' ? cb : rethrow();
-}
-
-// Ensure that callbacks run in the global context. Only use this function
-// for callbacks that are passed to the binding layer, callbacks that are
-// invoked from JS already run in the proper scope.
-function makeCallback(cb) {
- if (typeof cb !== 'function') {
- return rethrow();
- }
-
- return function() {
- return cb.apply(null, arguments);
- };
-}
-
-function assertEncoding(encoding) {
- if (encoding && !Buffer.isEncoding(encoding)) {
- throw new Error('Unknown encoding: ' + encoding);
- }
-}
-
-function nullCheck(path, callback) {
- if (('' + path).indexOf('\u0000') !== -1) {
- var er = new Error('Path must be a string without null bytes.');
- if (!callback)
- throw er;
- process.nextTick(function() {
- callback(er);
- });
- return false;
- }
- return true;
-}
-
-fs.Stats = binding.Stats;
-
-fs.Stats.prototype._checkModeProperty = function(property) {
- return ((this.mode & constants.S_IFMT) === property);
-};
-
-fs.Stats.prototype.isDirectory = function() {
- return this._checkModeProperty(constants.S_IFDIR);
-};
-
-fs.Stats.prototype.isFile = function() {
- return this._checkModeProperty(constants.S_IFREG);
-};
-
-fs.Stats.prototype.isBlockDevice = function() {
- return this._checkModeProperty(constants.S_IFBLK);
-};
-
-fs.Stats.prototype.isCharacterDevice = function() {
- return this._checkModeProperty(constants.S_IFCHR);
-};
-
-fs.Stats.prototype.isSymbolicLink = function() {
- return this._checkModeProperty(constants.S_IFLNK);
-};
-
-fs.Stats.prototype.isFIFO = function() {
- return this._checkModeProperty(constants.S_IFIFO);
-};
-
-fs.Stats.prototype.isSocket = function() {
- return this._checkModeProperty(constants.S_IFSOCK);
-};
-
-fs.exists = function(path, callback) {
- if (!nullCheck(path, cb)) return;
- binding.stat(pathModule._makeLong(path), cb);
- function cb(err, stats) {
- if (callback) callback(err ? false : true);
- }
-};
-
-fs.existsSync = function(path) {
- try {
- nullCheck(path);
- binding.stat(pathModule._makeLong(path));
- return true;
- } catch (e) {
- return false;
- }
-};
-
-fs.readFile = function(path, encoding_) {
- var encoding = typeof(encoding_) === 'string' ? encoding_ : null;
- var callback = maybeCallback(arguments[arguments.length - 1]);
-
- assertEncoding(encoding);
-
- // first, stat the file, so we know the size.
- var size;
- var buffer; // single buffer with file data
- var buffers; // list for when size is unknown
- var pos = 0;
- var fd;
-
- fs.open(path, constants.O_RDONLY, 438 /*=0666*/, function(er, fd_) {
- if (er) return callback(er);
- fd = fd_;
-
- fs.fstat(fd, function(er, st) {
- if (er) return callback(er);
- size = st.size;
- if (size === 0) {
- // the kernel lies about many files.
- // Go ahead and try to read some bytes.
- buffers = [];
- return read();
- }
-
- buffer = new Buffer(size);
- read();
- });
- });
-
- function read() {
- if (size === 0) {
- buffer = new Buffer(8192);
- fs.read(fd, buffer, 0, 8192, -1, afterRead);
- } else {
- fs.read(fd, buffer, pos, size - pos, -1, afterRead);
- }
- }
-
- function afterRead(er, bytesRead) {
- if (er) {
- return fs.close(fd, function(er2) {
- return callback(er);
- });
- }
-
- if (bytesRead === 0) {
- return close();
- }
-
- pos += bytesRead;
- if (size !== 0) {
- if (pos === size) close();
- else read();
- } else {
- // unknown size, just read until we don't get bytes.
- buffers.push(buffer.slice(0, bytesRead));
- read();
- }
- }
-
- function close() {
- fs.close(fd, function(er) {
- if (size === 0) {
- // collected the data into the buffers list.
- buffer = Buffer.concat(buffers, pos);
- } else if (pos < size) {
- buffer = buffer.slice(0, pos);
- }
-
- if (encoding) buffer = buffer.toString(encoding);
- return callback(er, buffer);
- });
- }
-};
-
-fs.readFileSync = function(path, encoding) {
- assertEncoding(encoding);
-
- var fd = fs.openSync(path, constants.O_RDONLY, 438 /*=0666*/);
-
- var size;
- var threw = true;
- try {
- size = fs.fstatSync(fd).size;
- threw = false;
- } finally {
- if (threw) fs.closeSync(fd);
- }
-
- var pos = 0;
- var buffer; // single buffer with file data
- var buffers; // list for when size is unknown
-
- if (size === 0) {
- buffers = [];
- } else {
- buffer = new Buffer(size);
- }
-
- var done = false;
- while (!done) {
- var threw = true;
- try {
- if (size !== 0) {
- var bytesRead = fs.readSync(fd, buffer, pos, size - pos);
- } else {
- // the kernel lies about many files.
- // Go ahead and try to read some bytes.
- buffer = new Buffer(8192);
- var bytesRead = fs.readSync(fd, buffer, 0, 8192);
- if (bytesRead) {
- buffers.push(buffer.slice(0, bytesRead));
- }
- }
- threw = false;
- } finally {
- if (threw) fs.closeSync(fd);
- }
-
- pos += bytesRead;
- done = (bytesRead === 0) || (size !== 0 && pos >= size);
- }
-
- fs.closeSync(fd);
-
- if (size === 0) {
- // data was collected into the buffers list.
- buffer = Buffer.concat(buffers, pos);
- } else if (pos < size) {
- buffer = buffer.slice(0, pos);
- }
-
- if (encoding) buffer = buffer.toString(encoding);
- return buffer;
-};
-
-
-// Used by binding.open and friends
-function stringToFlags(flag) {
- // Only mess with strings
- if (typeof flag !== 'string') {
- return flag;
- }
-
- // O_EXCL is mandated by POSIX, Windows supports it too.
- // Let's add a check anyway, just in case.
- if (!O_EXCL && ~flag.indexOf('x')) {
- throw errnoException('ENOSYS', 'fs.open(O_EXCL)');
- }
-
- switch (flag) {
- case 'r' : return O_RDONLY;
- case 'rs' : return O_RDONLY | O_SYNC;
- case 'r+' : return O_RDWR;
- case 'rs+' : return O_RDWR | O_SYNC;
-
- case 'w' : return O_TRUNC | O_CREAT | O_WRONLY;
- case 'wx' : // fall through
- case 'xw' : return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL;
-
- case 'w+' : return O_TRUNC | O_CREAT | O_RDWR;
- case 'wx+': // fall through
- case 'xw+': return O_TRUNC | O_CREAT | O_RDWR | O_EXCL;
-
- case 'a' : return O_APPEND | O_CREAT | O_WRONLY;
- case 'ax' : // fall through
- case 'xa' : return O_APPEND | O_CREAT | O_WRONLY | O_EXCL;
-
- case 'a+' : return O_APPEND | O_CREAT | O_RDWR;
- case 'ax+': // fall through
- case 'xa+': return O_APPEND | O_CREAT | O_RDWR | O_EXCL;
- }
-
- throw new Error('Unknown file open flag: ' + flag);
-}
-
-// exported but hidden, only used by test/simple/test-fs-open-flags.js
-Object.defineProperty(exports, '_stringToFlags', {
- enumerable: false,
- value: stringToFlags
-});
-
-
-// Yes, the follow could be easily DRYed up but I provide the explicit
-// list to make the arguments clear.
-
-fs.close = function(fd, callback) {
- binding.close(fd, makeCallback(callback));
-};
-
-fs.closeSync = function(fd) {
- return binding.close(fd);
-};
-
-function modeNum(m, def) {
- switch (typeof m) {
- case 'number': return m;
- case 'string': return parseInt(m, 8);
- default:
- if (def) {
- return modeNum(def);
- } else {
- return undefined;
- }
- }
-}
-
-fs.open = function(path, flags, mode, callback) {
- callback = makeCallback(arguments[arguments.length - 1]);
- mode = modeNum(mode, 438 /*=0666*/);
-
- if (!nullCheck(path, callback)) return;
- binding.open(pathModule._makeLong(path),
- stringToFlags(flags),
- mode,
- callback);
-};
-
-fs.openSync = function(path, flags, mode) {
- mode = modeNum(mode, 438 /*=0666*/);
- nullCheck(path);
- return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
-};
-
-fs.read = function(fd, buffer, offset, length, position, callback) {
- if (!Buffer.isBuffer(buffer)) {
- // legacy string interface (fd, length, position, encoding, callback)
- var cb = arguments[4],
- encoding = arguments[3];
-
- assertEncoding(encoding);
-
- position = arguments[2];
- length = arguments[1];
- buffer = new Buffer(length);
- offset = 0;
-
- callback = function(err, bytesRead) {
- if (!cb) return;
-
- var str = (bytesRead > 0) ? buffer.toString(encoding, 0, bytesRead) : '';
-
- (cb)(err, str, bytesRead);
- };
- }
-
- function wrapper(err, bytesRead) {
- // Retain a reference to buffer so that it can't be GC'ed too soon.
- callback && callback(err, bytesRead || 0, buffer);
- }
-
- binding.read(fd, buffer, offset, length, position, wrapper);
-};
-
-fs.readSync = function(fd, buffer, offset, length, position) {
- var legacy = false;
- if (!Buffer.isBuffer(buffer)) {
- // legacy string interface (fd, length, position, encoding, callback)
- legacy = true;
- var encoding = arguments[3];
-
- assertEncoding(encoding);
-
- position = arguments[2];
- length = arguments[1];
- buffer = new Buffer(length);
-
- offset = 0;
- }
-
- var r = binding.read(fd, buffer, offset, length, position);
- if (!legacy) {
- return r;
- }
-
- var str = (r > 0) ? buffer.toString(encoding, 0, r) : '';
- return [str, r];
-};
-
-fs.write = function(fd, buffer, offset, length, position, callback) {
- if (!Buffer.isBuffer(buffer)) {
- // legacy string interface (fd, data, position, encoding, callback)
- callback = arguments[4];
- position = arguments[2];
- assertEncoding(arguments[3]);
-
- buffer = new Buffer('' + arguments[1], arguments[3]);
- offset = 0;
- length = buffer.length;
- }
-
- if (!length) {
- if (typeof callback == 'function') {
- process.nextTick(function() {
- callback(undefined, 0);
- });
- }
- return;
- }
-
- callback = maybeCallback(callback);
-
- function wrapper(err, written) {
- // Retain a reference to buffer so that it can't be GC'ed too soon.
- callback(err, written || 0, buffer);
- }
-
- binding.write(fd, buffer, offset, length, position, wrapper);
-};
-
-fs.writeSync = function(fd, buffer, offset, length, position) {
- if (!Buffer.isBuffer(buffer)) {
- // legacy string interface (fd, data, position, encoding)
- position = arguments[2];
- assertEncoding(arguments[3]);
-
- buffer = new Buffer('' + arguments[1], arguments[3]);
- offset = 0;
- length = buffer.length;
- }
- if (!length) return 0;
-
- return binding.write(fd, buffer, offset, length, position);
-};
-
-fs.rename = function(oldPath, newPath, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(oldPath, callback)) return;
- if (!nullCheck(newPath, callback)) return;
- binding.rename(pathModule._makeLong(oldPath),
- pathModule._makeLong(newPath),
- callback);
-};
-
-fs.renameSync = function(oldPath, newPath) {
- nullCheck(oldPath);
- nullCheck(newPath);
- return binding.rename(pathModule._makeLong(oldPath),
- pathModule._makeLong(newPath));
-};
-
-fs.truncate = function(path, len, callback) {
- if (typeof path === 'number') {
- // legacy
- return fs.ftruncate(path, len, callback);
- }
- if (typeof len === 'function') {
- callback = len;
- len = 0;
- } else if (typeof len === 'undefined') {
- len = 0;
- }
- callback = maybeCallback(callback);
- fs.open(path, 'w', function(er, fd) {
- if (er) return callback(er);
- binding.ftruncate(fd, len, function(er) {
- fs.close(fd, function(er2) {
- callback(er || er2);
- });
- });
- });
-};
-
-fs.truncateSync = function(path, len) {
- if (typeof path === 'number') {
- // legacy
- return fs.ftruncateSync(path, len);
- }
- if (typeof len === 'undefined') {
- len = 0;
- }
- // allow error to be thrown, but still close fd.
- var fd = fs.openSync(path, 'w');
- try {
- var ret = fs.ftruncateSync(fd, len);
- } finally {
- fs.closeSync(fd);
- }
- return ret;
-};
-
-fs.ftruncate = function(fd, len, callback) {
- if (typeof len === 'function') {
- callback = len;
- len = 0;
- } else if (typeof len === 'undefined') {
- len = 0;
- }
- binding.ftruncate(fd, len, makeCallback(callback));
-};
-
-fs.ftruncateSync = function(fd, len) {
- if (typeof len === 'undefined') {
- len = 0;
- }
- return binding.ftruncate(fd, len);
-};
-
-fs.rmdir = function(path, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.rmdir(pathModule._makeLong(path), callback);
-};
-
-fs.rmdirSync = function(path) {
- nullCheck(path);
- return binding.rmdir(pathModule._makeLong(path));
-};
-
-fs.fdatasync = function(fd, callback) {
- binding.fdatasync(fd, makeCallback(callback));
-};
-
-fs.fdatasyncSync = function(fd) {
- return binding.fdatasync(fd);
-};
-
-fs.fsync = function(fd, callback) {
- binding.fsync(fd, makeCallback(callback));
-};
-
-fs.fsyncSync = function(fd) {
- return binding.fsync(fd);
-};
-
-fs.mkdir = function(path, mode, callback) {
- if (typeof mode === 'function') callback = mode;
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.mkdir(pathModule._makeLong(path),
- modeNum(mode, 511 /*=0777*/),
- callback);
-};
-
-fs.mkdirSync = function(path, mode) {
- nullCheck(path);
- return binding.mkdir(pathModule._makeLong(path),
- modeNum(mode, 511 /*=0777*/));
-};
-
-fs.sendfile = function(outFd, inFd, inOffset, length, callback) {
- binding.sendfile(outFd, inFd, inOffset, length, makeCallback(callback));
-};
-
-fs.sendfileSync = function(outFd, inFd, inOffset, length) {
- return binding.sendfile(outFd, inFd, inOffset, length);
-};
-
-fs.readdir = function(path, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.readdir(pathModule._makeLong(path), callback);
-};
-
-fs.readdirSync = function(path) {
- nullCheck(path);
- return binding.readdir(pathModule._makeLong(path));
-};
-
-fs.fstat = function(fd, callback) {
- binding.fstat(fd, makeCallback(callback));
-};
-
-fs.lstat = function(path, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.lstat(pathModule._makeLong(path), callback);
-};
-
-fs.stat = function(path, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.stat(pathModule._makeLong(path), callback);
-};
-
-fs.fstatSync = function(fd) {
- return binding.fstat(fd);
-};
-
-fs.lstatSync = function(path) {
- nullCheck(path);
- return binding.lstat(pathModule._makeLong(path));
-};
-
-fs.statSync = function(path) {
- nullCheck(path);
- return binding.stat(pathModule._makeLong(path));
-};
-
-fs.readlink = function(path, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.readlink(pathModule._makeLong(path), callback);
-};
-
-fs.readlinkSync = function(path) {
- nullCheck(path);
- return binding.readlink(pathModule._makeLong(path));
-};
-
-function preprocessSymlinkDestination(path, type) {
- if (!isWindows) {
- // No preprocessing is needed on Unix.
- return path;
- } else if (type === 'junction') {
- // Junctions paths need to be absolute and \\?\-prefixed.
- return pathModule._makeLong(path);
- } else {
- // Windows symlinks don't tolerate forward slashes.
- return ('' + path).replace(/\//g, '\\');
- }
-}
-
-fs.symlink = function(destination, path, type_, callback) {
- var type = (typeof type_ === 'string' ? type_ : null);
- var callback = makeCallback(arguments[arguments.length - 1]);
-
- if (!nullCheck(destination, callback)) return;
- if (!nullCheck(path, callback)) return;
-
- binding.symlink(preprocessSymlinkDestination(destination, type),
- pathModule._makeLong(path),
- type,
- callback);
-};
-
-fs.symlinkSync = function(destination, path, type) {
- type = (typeof type === 'string' ? type : null);
-
- nullCheck(destination);
- nullCheck(path);
-
- return binding.symlink(preprocessSymlinkDestination(destination, type),
- pathModule._makeLong(path),
- type);
-};
-
-fs.link = function(srcpath, dstpath, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(srcpath, callback)) return;
- if (!nullCheck(dstpath, callback)) return;
-
- binding.link(pathModule._makeLong(srcpath),
- pathModule._makeLong(dstpath),
- callback);
-};
-
-fs.linkSync = function(srcpath, dstpath) {
- nullCheck(srcpath);
- nullCheck(dstpath);
- return binding.link(pathModule._makeLong(srcpath),
- pathModule._makeLong(dstpath));
-};
-
-fs.unlink = function(path, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.unlink(pathModule._makeLong(path), callback);
-};
-
-fs.unlinkSync = function(path) {
- nullCheck(path);
- return binding.unlink(pathModule._makeLong(path));
-};
-
-fs.fchmod = function(fd, mode, callback) {
- binding.fchmod(fd, modeNum(mode), makeCallback(callback));
-};
-
-fs.fchmodSync = function(fd, mode) {
- return binding.fchmod(fd, modeNum(mode));
-};
-
-if (constants.hasOwnProperty('O_SYMLINK')) {
- fs.lchmod = function(path, mode, callback) {
- callback = maybeCallback(callback);
- fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function(err, fd) {
- if (err) {
- callback(err);
- return;
- }
- // prefer to return the chmod error, if one occurs,
- // but still try to close, and report closing errors if they occur.
- fs.fchmod(fd, mode, function(err) {
- fs.close(fd, function(err2) {
- callback(err || err2);
- });
- });
- });
- };
-
- fs.lchmodSync = function(path, mode) {
- var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
-
- // prefer to return the chmod error, if one occurs,
- // but still try to close, and report closing errors if they occur.
- var err, err2;
- try {
- var ret = fs.fchmodSync(fd, mode);
- } catch (er) {
- err = er;
- }
- try {
- fs.closeSync(fd);
- } catch (er) {
- err2 = er;
- }
- if (err || err2) throw (err || err2);
- return ret;
- };
-}
-
-
-fs.chmod = function(path, mode, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.chmod(pathModule._makeLong(path),
- modeNum(mode),
- callback);
-};
-
-fs.chmodSync = function(path, mode) {
- nullCheck(path);
- return binding.chmod(pathModule._makeLong(path), modeNum(mode));
-};
-
-if (constants.hasOwnProperty('O_SYMLINK')) {
- fs.lchown = function(path, uid, gid, callback) {
- callback = maybeCallback(callback);
- fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, function(err, fd) {
- if (err) {
- callback(err);
- return;
- }
- fs.fchown(fd, uid, gid, callback);
- });
- };
-
- fs.lchownSync = function(path, uid, gid) {
- var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK);
- return fs.fchownSync(fd, uid, gid);
- };
-}
-
-fs.fchown = function(fd, uid, gid, callback) {
- binding.fchown(fd, uid, gid, makeCallback(callback));
-};
-
-fs.fchownSync = function(fd, uid, gid) {
- return binding.fchown(fd, uid, gid);
-};
-
-fs.chown = function(path, uid, gid, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.chown(pathModule._makeLong(path), uid, gid, callback);
-};
-
-fs.chownSync = function(path, uid, gid) {
- nullCheck(path);
- return binding.chown(pathModule._makeLong(path), uid, gid);
-};
-
-// converts Date or number to a fractional UNIX timestamp
-function toUnixTimestamp(time) {
- if (typeof time == 'number') {
- return time;
- }
- if (time instanceof Date) {
- // convert to 123.456 UNIX timestamp
- return time.getTime() / 1000;
- }
- throw new Error('Cannot parse time: ' + time);
-}
-
-// exported for unit tests, not for public consumption
-fs._toUnixTimestamp = toUnixTimestamp;
-
-fs.utimes = function(path, atime, mtime, callback) {
- callback = makeCallback(callback);
- if (!nullCheck(path, callback)) return;
- binding.utimes(pathModule._makeLong(path),
- toUnixTimestamp(atime),
- toUnixTimestamp(mtime),
- callback);
-};
-
-fs.utimesSync = function(path, atime, mtime) {
- nullCheck(path);
- atime = toUnixTimestamp(atime);
- mtime = toUnixTimestamp(mtime);
- binding.utimes(pathModule._makeLong(path), atime, mtime);
-};
-
-fs.futimes = function(fd, atime, mtime, callback) {
- atime = toUnixTimestamp(atime);
- mtime = toUnixTimestamp(mtime);
- binding.futimes(fd, atime, mtime, makeCallback(callback));
-};
-
-fs.futimesSync = function(fd, atime, mtime) {
- atime = toUnixTimestamp(atime);
- mtime = toUnixTimestamp(mtime);
- binding.futimes(fd, atime, mtime);
-};
-
-function writeAll(fd, buffer, offset, length, position, callback) {
- callback = maybeCallback(arguments[arguments.length - 1]);
-
- // write(fd, buffer, offset, length, position, callback)
- fs.write(fd, buffer, offset, length, position, function(writeErr, written) {
- if (writeErr) {
- fs.close(fd, function() {
- if (callback) callback(writeErr);
- });
- } else {
- if (written === length) {
- fs.close(fd, callback);
- } else {
- offset += written;
- length -= written;
- position += written;
- writeAll(fd, buffer, offset, length, position, callback);
- }
- }
- });
-}
-
-fs.writeFile = function(path, data, encoding_, callback) {
- var encoding = (typeof(encoding_) == 'string' ? encoding_ : 'utf8');
- assertEncoding(encoding);
-
- callback = maybeCallback(arguments[arguments.length - 1]);
- fs.open(path, 'w', 438 /*=0666*/, function(openErr, fd) {
- if (openErr) {
- if (callback) callback(openErr);
- } else {
- var buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data,
- encoding);
- writeAll(fd, buffer, 0, buffer.length, 0, callback);
- }
- });
-};
-
-fs.writeFileSync = function(path, data, encoding) {
- assertEncoding(encoding);
-
- var fd = fs.openSync(path, 'w');
- if (!Buffer.isBuffer(data)) {
- data = new Buffer('' + data, encoding || 'utf8');
- }
- var written = 0;
- var length = data.length;
- try {
- while (written < length) {
- written += fs.writeSync(fd, data, written, length - written, written);
- }
- } finally {
- fs.closeSync(fd);
- }
-};
-
-fs.appendFile = function(path, data, encoding_, callback) {
- var encoding = (typeof(encoding_) == 'string' ? encoding_ : 'utf8');
- assertEncoding(encoding);
-
- callback = maybeCallback(arguments[arguments.length - 1]);
-
- fs.open(path, 'a', 438 /*=0666*/, function(err, fd) {
- if (err) return callback(err);
- var buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data, encoding);
- writeAll(fd, buffer, 0, buffer.length, null, callback);
- });
-};
-
-fs.appendFileSync = function(path, data, encoding) {
- assertEncoding(encoding);
-
- var fd = fs.openSync(path, 'a');
- if (!Buffer.isBuffer(data)) {
- data = new Buffer('' + data, encoding || 'utf8');
- }
- var written = 0;
- var position = null;
- var length = data.length;
-
- try {
- while (written < length) {
- written += fs.writeSync(fd, data, written, length - written, position);
- position += written; // XXX not safe with multiple concurrent writers?
- }
- } finally {
- fs.closeSync(fd);
- }
-};
-
-function errnoException(errorno, syscall) {
- // TODO make this more compatible with ErrnoException from src/node.cc
- // Once all of Node is using this function the ErrnoException from
- // src/node.cc should be removed.
- var e = new Error(syscall + ' ' + errorno);
- e.errno = e.code = errorno;
- e.syscall = syscall;
- return e;
-}
-
-
-function FSWatcher() {
- EventEmitter.call(this);
-
- var self = this;
- var FSEvent = process.binding('fs_event_wrap').FSEvent;
- this._handle = new FSEvent();
- this._handle.owner = this;
-
- this._handle.onchange = function(status, event, filename) {
- if (status) {
- self._handle.close();
- self.emit('error', errnoException(errno, 'watch'));
- } else {
- self.emit('change', event, filename);
- }
- };
-}
-util.inherits(FSWatcher, EventEmitter);
-
-FSWatcher.prototype.start = function(filename, persistent) {
- nullCheck(filename);
- var r = this._handle.start(pathModule._makeLong(filename), persistent);
-
- if (r) {
- this._handle.close();
- throw errnoException(errno, 'watch');
- }
-};
-
-FSWatcher.prototype.close = function() {
- this._handle.close();
-};
-
-fs.watch = function(filename) {
- nullCheck(filename);
- var watcher;
- var options;
- var listener;
-
- if ('object' == typeof arguments[1]) {
- options = arguments[1];
- listener = arguments[2];
- } else {
- options = {};
- listener = arguments[1];
- }
-
- if (options.persistent === undefined) options.persistent = true;
-
- watcher = new FSWatcher();
- watcher.start(filename, options.persistent);
-
- if (listener) {
- watcher.addListener('change', listener);
- }
-
- return watcher;
-};
-
-
-// Stat Change Watchers
-
-function StatWatcher() {
- EventEmitter.call(this);
-
- var self = this;
- this._handle = new binding.StatWatcher();
-
- // uv_fs_poll is a little more powerful than ev_stat but we curb it for
- // the sake of backwards compatibility
- var oldStatus = -1;
-
- this._handle.onchange = function(current, previous, newStatus) {
- if (oldStatus === -1 &&
- newStatus === -1 &&
- current.nlink === previous.nlink) return;
-
- oldStatus = newStatus;
- self.emit('change', current, previous);
- };
-
- this._handle.onstop = function() {
- self.emit('stop');
- };
-}
-util.inherits(StatWatcher, EventEmitter);
-
-
-StatWatcher.prototype.start = function(filename, persistent, interval) {
- nullCheck(filename);
- this._handle.start(pathModule._makeLong(filename), persistent, interval);
-};
-
-
-StatWatcher.prototype.stop = function() {
- this._handle.stop();
-};
-
-
-var statWatchers = {};
-function inStatWatchers(filename) {
- return Object.prototype.hasOwnProperty.call(statWatchers, filename) &&
- statWatchers[filename];
-}
-
-
-fs.watchFile = function(filename) {
- nullCheck(filename);
- var stat;
- var listener;
-
- var options = {
- // Poll interval in milliseconds. 5007 is what libev used to use. It's
- // a little on the slow side but let's stick with it for now to keep
- // behavioral changes to a minimum.
- interval: 5007,
- persistent: true
- };
-
- if ('object' == typeof arguments[1]) {
- options = util._extend(options, arguments[1]);
- listener = arguments[2];
- } else {
- listener = arguments[1];
- }
-
- if (!listener) {
- throw new Error('watchFile requires a listener function');
- }
-
- if (inStatWatchers(filename)) {
- stat = statWatchers[filename];
- } else {
- stat = statWatchers[filename] = new StatWatcher();
- stat.start(filename, options.persistent, options.interval);
- }
- stat.addListener('change', listener);
- return stat;
-};
-
-fs.unwatchFile = function(filename, listener) {
- nullCheck(filename);
- if (!inStatWatchers(filename)) return;
-
- var stat = statWatchers[filename];
-
- if (typeof listener === 'function') {
- stat.removeListener('change', listener);
- } else {
- stat.removeAllListeners('change');
- }
-
- if (stat.listeners('change').length === 0) {
- stat.stop();
- statWatchers[filename] = undefined;
- }
-};
-
-// Realpath
-// Not using realpath(2) because it's bad.
-// See: http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
-
-var normalize = pathModule.normalize;
-
-// Regexp that finds the next partion of a (partial) path
-// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
-if (isWindows) {
- var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
-} else {
- var nextPartRe = /(.*?)(?:[\/]+|$)/g;
-}
-
-// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
-if (isWindows) {
- var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
-} else {
- var splitRootRe = /^[\/]*/;
-}
-
-fs.realpathSync = function realpathSync(p, cache) {
- // make p is absolute
- p = pathModule.resolve(p);
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
- return cache[p];
- }
-
- var original = p,
- seenLinks = {},
- knownHard = {};
-
- // current character position in p
- var pos;
- // the partial path so far, including a trailing slash if any
- var current;
- // the partial path without a trailing slash (except when pointing at a root)
- var base;
- // the partial path scanned in the previous round, with slash
- var previous;
-
- start();
-
- function start() {
- // Skip over roots
- var m = splitRootRe.exec(p);
- pos = m[0].length;
- current = m[0];
- base = m[0];
- previous = '';
-
- // On windows, check that the root exists. On unix there is no need.
- if (isWindows && !knownHard[base]) {
- fs.lstatSync(base);
- knownHard[base] = true;
- }
- }
-
- // walk down the path, swapping out linked pathparts for their real
- // values
- // NB: p.length changes.
- while (pos < p.length) {
- // find the next part
- nextPartRe.lastIndex = pos;
- var result = nextPartRe.exec(p);
- previous = current;
- current += result[0];
- base = previous + result[1];
- pos = nextPartRe.lastIndex;
-
- // continue if not a symlink
- if (knownHard[base] || (cache && cache[base] === base)) {
- continue;
- }
-
- var resolvedLink;
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
- // some known symbolic link. no need to stat again.
- resolvedLink = cache[base];
- } else {
- var stat = fs.lstatSync(base);
- if (!stat.isSymbolicLink()) {
- knownHard[base] = true;
- if (cache) cache[base] = base;
- continue;
- }
-
- // read the link if it wasn't read before
- // dev/ino always return 0 on windows, so skip the check.
- var linkTarget = null;
- if (!isWindows) {
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
- if (seenLinks.hasOwnProperty(id)) {
- linkTarget = seenLinks[id];
- }
- }
- if (linkTarget === null) {
- fs.statSync(base);
- linkTarget = fs.readlinkSync(base);
- }
- resolvedLink = pathModule.resolve(previous, linkTarget);
- // track this, if given a cache.
- if (cache) cache[base] = resolvedLink;
- if (!isWindows) seenLinks[id] = linkTarget;
- }
-
- // resolve the link, then start over
- p = pathModule.resolve(resolvedLink, p.slice(pos));
- start();
- }
-
- if (cache) cache[original] = p;
-
- return p;
-};
-
-
-fs.realpath = function realpath(p, cache, cb) {
- if (typeof cb !== 'function') {
- cb = maybeCallback(cache);
- cache = null;
- }
-
- // make p is absolute
- p = pathModule.resolve(p);
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
- return process.nextTick(cb.bind(null, null, cache[p]));
- }
-
- var original = p,
- seenLinks = {},
- knownHard = {};
-
- // current character position in p
- var pos;
- // the partial path so far, including a trailing slash if any
- var current;
- // the partial path without a trailing slash (except when pointing at a root)
- var base;
- // the partial path scanned in the previous round, with slash
- var previous;
-
- start();
-
- function start() {
- // Skip over roots
- var m = splitRootRe.exec(p);
- pos = m[0].length;
- current = m[0];
- base = m[0];
- previous = '';
-
- // On windows, check that the root exists. On unix there is no need.
- if (isWindows && !knownHard[base]) {
- fs.lstat(base, function(err) {
- if (err) return cb(err);
- knownHard[base] = true;
- LOOP();
- });
- } else {
- process.nextTick(LOOP);
- }
- }
-
- // walk down the path, swapping out linked pathparts for their real
- // values
- function LOOP() {
- // stop if scanned past end of path
- if (pos >= p.length) {
- if (cache) cache[original] = p;
- return cb(null, p);
- }
-
- // find the next part
- nextPartRe.lastIndex = pos;
- var result = nextPartRe.exec(p);
- previous = current;
- current += result[0];
- base = previous + result[1];
- pos = nextPartRe.lastIndex;
-
- // continue if not a symlink
- if (knownHard[base] || (cache && cache[base] === base)) {
- return process.nextTick(LOOP);
- }
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
- // known symbolic link. no need to stat again.
- return gotResolvedLink(cache[base]);
- }
-
- return fs.lstat(base, gotStat);
- }
-
- function gotStat(err, stat) {
- if (err) return cb(err);
-
- // if not a symlink, skip to the next path part
- if (!stat.isSymbolicLink()) {
- knownHard[base] = true;
- if (cache) cache[base] = base;
- return process.nextTick(LOOP);
- }
-
- // stat & read the link if not read before
- // call gotTarget as soon as the link target is known
- // dev/ino always return 0 on windows, so skip the check.
- if (!isWindows) {
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
- if (seenLinks.hasOwnProperty(id)) {
- return gotTarget(null, seenLinks[id], base);
- }
- }
- fs.stat(base, function(err) {
- if (err) return cb(err);
-
- fs.readlink(base, function(err, target) {
- if (!isWindows) seenLinks[id] = target;
- gotTarget(err, target);
- });
- });
- }
-
- function gotTarget(err, target, base) {
- if (err) return cb(err);
-
- var resolvedLink = pathModule.resolve(previous, target);
- if (cache) cache[base] = resolvedLink;
- gotResolvedLink(resolvedLink);
- }
-
- function gotResolvedLink(resolvedLink) {
- // resolve the link, then start over
- p = pathModule.resolve(resolvedLink, p.slice(pos));
- start();
- }
-};
-
-
-
-var pool;
-
-function allocNewPool() {
- pool = new Buffer(kPoolSize);
- pool.used = 0;
-}
-
-
-
-fs.createReadStream = function(path, options) {
- return new ReadStream(path, options);
-};
-
-util.inherits(ReadStream, Readable);
-fs.ReadStream = ReadStream;
-
-function ReadStream(path, options) {
- if (!(this instanceof ReadStream))
- return new ReadStream(path, options);
-
- // a little bit bigger buffer and water marks by default
- options = util._extend({
- bufferSize: 64 * 1024,
- lowWaterMark: 16 * 1024,
- highWaterMark: 64 * 1024
- }, options || {});
-
- Readable.call(this, options);
-
- this.path = path;
- this.fd = options.hasOwnProperty('fd') ? options.fd : null;
- this.flags = options.hasOwnProperty('flags') ? options.flags : 'r';
- this.mode = options.hasOwnProperty('mode') ? options.mode : 438; /*=0666*/
-
- this.start = options.hasOwnProperty('start') ? options.start : undefined;
- this.end = options.hasOwnProperty('start') ? options.end : undefined;
- this.pos = undefined;
-
- if (this.start !== undefined) {
- if ('number' !== typeof this.start) {
- throw TypeError('start must be a Number');
- }
- if (this.end === undefined) {
- this.end = Infinity;
- } else if ('number' !== typeof this.end) {
- throw TypeError('end must be a Number');
- }
-
- if (this.start > this.end) {
- throw new Error('start must be <= end');
- }
-
- this.pos = this.start;
- }
-
- if (typeof this.fd !== 'number')
- this.open();
-
- this.on('end', function() {
- this.destroy();
- });
-}
-
-fs.FileReadStream = fs.ReadStream; // support the legacy name
-
-ReadStream.prototype.open = function() {
- var self = this;
- fs.open(this.path, this.flags, this.mode, function(er, fd) {
- if (er) {
- self.destroy();
- self.emit('error', er);
- return;
- }
-
- self.fd = fd;
- self.emit('open', fd);
- // start the flow of data.
- self.read();
- });
-};
-
-ReadStream.prototype._read = function(n, cb) {
- if (typeof this.fd !== 'number')
- return this.once('open', function() {
- this._read(n, cb);
- });
-
- if (this.destroyed)
- return;
-
- if (!pool || pool.length - pool.used < kMinPoolSpace) {
- // discard the old pool. Can't add to the free list because
- // users might have refernces to slices on it.
- pool = null;
- allocNewPool();
- }
-
- // Grab another reference to the pool in the case that while we're
- // in the thread pool another read() finishes up the pool, and
- // allocates a new one.
- var thisPool = pool;
- var toRead = Math.min(pool.length - pool.used, n);
- var start = pool.used;
-
- if (this.pos !== undefined)
- toRead = Math.min(this.end - this.pos + 1, toRead);
-
- // already read everything we were supposed to read!
- // treat as EOF.
- if (toRead <= 0)
- return cb();
-
- // the actual read.
- var self = this;
- fs.read(this.fd, pool, pool.used, toRead, this.pos, onread);
-
- // move the pool positions, and internal position for reading.
- if (this.pos !== undefined)
- this.pos += toRead;
- pool.used += toRead;
-
- function onread(er, bytesRead) {
- if (er) {
- self.destroy();
- return cb(er);
- }
-
- var b = null;
- if (bytesRead > 0)
- b = thisPool.slice(start, start + bytesRead);
-
- cb(null, b);
- }
-};
-
-
-ReadStream.prototype.destroy = function() {
- if (this.destroyed)
- return;
- this.destroyed = true;
- if ('number' === typeof this.fd)
- this.close();
-};
-
-
-ReadStream.prototype.close = function(cb) {
- if (cb)
- this.once('close', cb);
- if (this.closed || 'number' !== typeof this.fd) {
- if ('number' !== typeof this.fd)
- this.once('open', close);
- return process.nextTick(this.emit.bind(this, 'close'));
- }
- this.closed = true;
- var self = this;
- close();
-
- function close() {
- fs.close(self.fd, function(er) {
- if (er)
- self.emit('error', er);
- else
- self.emit('close');
- });
- }
-};
-
-
-
-
-fs.createWriteStream = function(path, options) {
- return new WriteStream(path, options);
-};
-
-util.inherits(WriteStream, Writable);
-fs.WriteStream = WriteStream;
-function WriteStream(path, options) {
- if (!(this instanceof WriteStream))
- return new WriteStream(path, options);
-
- // a little bit bigger buffer and water marks by default
- options = util._extend({
- bufferSize: 64 * 1024,
- lowWaterMark: 16 * 1024,
- highWaterMark: 64 * 1024
- }, options || {});
-
- Writable.call(this, options);
-
- this.path = path;
- this.fd = null;
-
- this.fd = options.hasOwnProperty('fd') ? options.fd : null;
- this.flags = options.hasOwnProperty('flags') ? options.flags : 'w';
- this.mode = options.hasOwnProperty('mode') ? options.mode : 438; /*=0666*/
-
- this.start = options.hasOwnProperty('start') ? options.start : undefined;
- this.pos = undefined;
- this.bytesWritten = 0;
-
- if (this.start !== undefined) {
- if ('number' !== typeof this.start) {
- throw TypeError('start must be a Number');
- }
- if (this.start < 0) {
- throw new Error('start must be >= zero');
- }
-
- this.pos = this.start;
- }
-
- if ('number' !== typeof this.fd)
- this.open();
-
- // dispose on finish.
- this.once('finish', this.close);
-}
-
-fs.FileWriteStream = fs.WriteStream; // support the legacy name
-
-
-WriteStream.prototype.open = function() {
- fs.open(this.path, this.flags, this.mode, function(er, fd) {
- if (er) {
- this.destroy();
- this.emit('error', er);
- return;
- }
-
- this.fd = fd;
- this.emit('open', fd);
- }.bind(this));
-};
-
-
-WriteStream.prototype._write = function(data, cb) {
- if (!Buffer.isBuffer(data))
- return this.emit('error', new Error('Invalid data'));
-
- if (typeof this.fd !== 'number')
- return this.once('open', this._write.bind(this, data, cb));
-
- fs.write(this.fd, data, 0, data.length, this.pos, function(er, bytes) {
- if (er) {
- this.destroy();
- return cb(er);
- }
- this.bytesWritten += bytes;
- cb();
- }.bind(this));
-
- if (this.pos !== undefined)
- this.pos += data.length;
-};
-
-
-WriteStream.prototype.destroy = ReadStream.prototype.destroy;
-WriteStream.prototype.close = ReadStream.prototype.close;
-
-// There is no shutdown() for files.
-WriteStream.prototype.destroySoon = WriteStream.prototype.end;
-
-
-// SyncWriteStream is internal. DO NOT USE.
-// Temporary hack for process.stdout and process.stderr when piped to files.
-function SyncWriteStream(fd) {
- Stream.call(this);
-
- this.fd = fd;
- this.writable = true;
- this.readable = false;
-}
-
-util.inherits(SyncWriteStream, Stream);
-
-
-// Export
-fs.SyncWriteStream = SyncWriteStream;
-
-
-SyncWriteStream.prototype.write = function(data, arg1, arg2) {
- var encoding, cb;
-
- // parse arguments
- if (arg1) {
- if (typeof arg1 === 'string') {
- encoding = arg1;
- cb = arg2;
- } else if (typeof arg1 === 'function') {
- cb = arg1;
- } else {
- throw new Error('bad arg');
- }
- }
- assertEncoding(encoding);
-
- // Change strings to buffers. SLOW
- if (typeof data == 'string') {
- data = new Buffer(data, encoding);
- }
-
- fs.writeSync(this.fd, data, 0, data.length);
-
- if (cb) {
- process.nextTick(cb);
- }
-
- return true;
-};
-
-
-SyncWriteStream.prototype.end = function(data, arg1, arg2) {
- if (data) {
- this.write(data, arg1, arg2);
- }
- this.destroy();
-};
-
-
-SyncWriteStream.prototype.destroy = function() {
- fs.closeSync(this.fd);
- this.fd = null;
- this.emit('close');
- return true;
-};
-
-SyncWriteStream.prototype.destroySoon = SyncWriteStream.prototype.destroy;
function onEofChunk(stream, state) {
- if (state.decoder && !state.ended) {
+ if (state.decoder && !state.ended && state.decoder.end) {
var chunk = state.decoder.end();
if (chunk && chunk.length) {
state.buffer.push(chunk);
}
// This is a brutally ugly hack to make sure that our error handler
// is attached before any userland ones. NEVER DO THIS.
- if (!dest._events.error)
+ if (!dest._events || !dest._events.error)
dest.on('error', onerror);
else if (Array.isArray(dest._events.error))
dest._events.error.unshift(onerror);
Transform.prototype._read = function(n) {
var ts = this._transformState;
- if (ts.writechunk && ts.writecb && !ts.transforming) {
+ if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
ts.transforming = true;
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
} else {
// If we return false, then we need a drain event, so set that flag.
function writeOrBuffer(stream, state, chunk, encoding, cb) {
chunk = decodeChunk(state, chunk, encoding);
+ if (Buffer.isBuffer(chunk))
+ encoding = 'buffer';
var len = state.objectMode ? 1 : chunk.length;
state.length += len;
{
"name": "readable-stream",
- "version": "1.0.17",
+ "version": "1.0.24",
"description": "An exploration of a new kind of readable streams for Node.js",
"main": "readable.js",
"dependencies": {},
"bugs": {
"url": "https://github.com/isaacs/readable-stream/issues"
},
- "_id": "readable-stream@1.0.17",
- "dist": {
- "shasum": "cbc295fdf394dfa1225d225d02e6b6d0f409fd4b"
- },
- "_from": "readable-stream@1.0",
- "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.17.tgz"
+ "homepage": "https://github.com/isaacs/readable-stream",
+ "_id": "readable-stream@1.0.24",
+ "_from": "readable-stream@1.0"
}
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var path = require('path');
-var assert = require('assert');
-
-exports.testDir = path.dirname(__filename);
-exports.fixturesDir = path.join(exports.testDir, 'fixtures');
-exports.libDir = path.join(exports.testDir, '../lib');
-exports.tmpDir = path.join(exports.testDir, 'tmp');
-exports.PORT = 12346;
-
-if (process.platform === 'win32') {
- exports.PIPE = '\\\\.\\pipe\\libuv-test';
-} else {
- exports.PIPE = exports.tmpDir + '/test.sock';
-}
-
-var util = require('util');
-for (var i in util) exports[i] = util[i];
-//for (var i in exports) global[i] = exports[i];
-
-function protoCtrChain(o) {
- var result = [];
- for (; o; o = o.__proto__) { result.push(o.constructor); }
- return result.join();
-}
-
-exports.indirectInstanceOf = function(obj, cls) {
- if (obj instanceof cls) { return true; }
- var clsChain = protoCtrChain(cls.prototype);
- var objChain = protoCtrChain(obj);
- return objChain.slice(-clsChain.length) === clsChain;
-};
-
-
-exports.ddCommand = function(filename, kilobytes) {
- if (process.platform === 'win32') {
- var p = path.resolve(exports.fixturesDir, 'create-file.js');
- return '"' + process.argv[0] + '" "' + p + '" "' +
- filename + '" ' + (kilobytes * 1024);
- } else {
- return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes;
- }
-};
-
-
-exports.spawnPwd = function(options) {
- var spawn = require('child_process').spawn;
-
- if (process.platform === 'win32') {
- return spawn('cmd.exe', ['/c', 'cd'], options);
- } else {
- return spawn('pwd', [], options);
- }
-};
-
-
-// Turn this off if the test should not check for global leaks.
-exports.globalCheck = true;
-
-process.on('exit', function() {
- if (!exports.globalCheck) return;
- var knownGlobals = [setTimeout,
- setInterval,
- global.setImmediate,
- clearTimeout,
- clearInterval,
- global.clearImmediate,
- console,
- Buffer,
- process,
- global];
-
- if (global.errno) {
- knownGlobals.push(errno);
- }
-
- if (global.gc) {
- knownGlobals.push(gc);
- }
-
- if (global.DTRACE_HTTP_SERVER_RESPONSE) {
- knownGlobals.push(DTRACE_HTTP_SERVER_RESPONSE);
- knownGlobals.push(DTRACE_HTTP_SERVER_REQUEST);
- knownGlobals.push(DTRACE_HTTP_CLIENT_RESPONSE);
- knownGlobals.push(DTRACE_HTTP_CLIENT_REQUEST);
- knownGlobals.push(DTRACE_NET_STREAM_END);
- knownGlobals.push(DTRACE_NET_SERVER_CONNECTION);
- knownGlobals.push(DTRACE_NET_SOCKET_READ);
- knownGlobals.push(DTRACE_NET_SOCKET_WRITE);
- }
- if (global.COUNTER_NET_SERVER_CONNECTION) {
- knownGlobals.push(COUNTER_NET_SERVER_CONNECTION);
- knownGlobals.push(COUNTER_NET_SERVER_CONNECTION_CLOSE);
- knownGlobals.push(COUNTER_HTTP_SERVER_REQUEST);
- knownGlobals.push(COUNTER_HTTP_SERVER_RESPONSE);
- knownGlobals.push(COUNTER_HTTP_CLIENT_REQUEST);
- knownGlobals.push(COUNTER_HTTP_CLIENT_RESPONSE);
- }
-
- if (global.ArrayBuffer) {
- knownGlobals.push(ArrayBuffer);
- knownGlobals.push(Int8Array);
- knownGlobals.push(Uint8Array);
- knownGlobals.push(Uint8ClampedArray);
- knownGlobals.push(Int16Array);
- knownGlobals.push(Uint16Array);
- knownGlobals.push(Int32Array);
- knownGlobals.push(Uint32Array);
- knownGlobals.push(Float32Array);
- knownGlobals.push(Float64Array);
- knownGlobals.push(DataView);
- }
-
- for (var x in global) {
- var found = false;
-
- for (var y in knownGlobals) {
- if (global[x] === knownGlobals[y]) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- console.error('Unknown global: %s', x);
- assert.ok(false, 'Unknown global found');
- }
- }
-});
-
-
-var mustCallChecks = [];
-
-
-function runCallChecks() {
- var failed = mustCallChecks.filter(function(context) {
- return context.actual !== context.expected;
- });
-
- failed.forEach(function(context) {
- console.log('Mismatched %s function calls. Expected %d, actual %d.',
- context.name,
- context.expected,
- context.actual);
- console.log(context.stack.split('\n').slice(2).join('\n'));
- });
-
- if (failed.length) process.exit(1);
-}
-
-
-exports.mustCall = function(fn, expected) {
- if (typeof expected !== 'number') expected = 1;
-
- var context = {
- expected: expected,
- actual: 0,
- stack: (new Error).stack,
- name: fn.name || '<anonymous>'
- };
-
- // add the exit listener only once to avoid listener leak warnings
- if (mustCallChecks.length === 0) process.on('exit', runCallChecks);
-
- mustCallChecks.push(context);
-
- return function() {
- context.actual++;
- return fn.apply(this, arguments);
- };
-};
+++ /dev/null
-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\ No newline at end of file
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-
-var common = require('../common.js');
-var R = require('../../lib/_stream_readable');
-var assert = require('assert');
-
-var util = require('util');
-var EE = require('events').EventEmitter;
-
-function TestReader(n) {
- R.apply(this);
- this._buffer = new Buffer(n || 100);
- this._buffer.fill('x');
- this._pos = 0;
- this._bufs = 10;
-}
-
-util.inherits(TestReader, R);
-
-TestReader.prototype.read = function(n) {
- if (n === 0) return null;
- var max = this._buffer.length - this._pos;
- n = n || max;
- n = Math.max(n, 0);
- var toRead = Math.min(n, max);
- if (toRead === 0) {
- // simulate the read buffer filling up with some more bytes some time
- // in the future.
- setTimeout(function() {
- this._pos = 0;
- this._bufs -= 1;
- if (this._bufs <= 0) {
- // read them all!
- if (!this.ended) {
- this.emit('end');
- this.ended = true;
- }
- } else {
- this.emit('readable');
- }
- }.bind(this), 10);
- return null;
- }
-
- var ret = this._buffer.slice(this._pos, this._pos + toRead);
- this._pos += toRead;
- return ret;
-};
-
-/////
-
-function TestWriter() {
- EE.apply(this);
- this.received = [];
- this.flush = false;
-}
-
-util.inherits(TestWriter, EE);
-
-TestWriter.prototype.write = function(c) {
- this.received.push(c.toString());
- this.emit('write', c);
- return true;
-};
-
-TestWriter.prototype.end = function(c) {
- if (c) this.write(c);
- this.emit('end', this.received);
-};
-
-////////
-
-// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
-
-function test(name, fn) {
- count++;
- tests.push([name, fn]);
-}
-
-function run() {
- var next = tests.shift();
- if (!next)
- return console.error('ok');
-
- var name = next[0];
- var fn = next[1];
- console.log('# %s', name);
- fn({
- same: assert.deepEqual,
- ok: assert,
- equal: assert.equal,
- end: function () {
- count--;
- run();
- }
- });
-}
-
-// ensure all tests have run
-process.on("exit", function () {
- assert.equal(count, 0);
-});
-
-process.nextTick(run);
-
-
-test('a most basic test', function(t) {
- var r = new TestReader(20);
-
- var reads = [];
- var expect = [ 'x',
- 'xx',
- 'xxx',
- 'xxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxxxxx',
- 'xxxxxxxxx',
- 'xxx',
- 'xxxxxxxxxxxx',
- 'xxxxxxxx',
- 'xxxxxxxxxxxxxxx',
- 'xxxxx',
- 'xxxxxxxxxxxxxxxxxx',
- 'xx',
- 'xxxxxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxxx' ];
-
- r.on('end', function() {
- t.same(reads, expect);
- t.end();
- });
-
- var readSize = 1;
- function flow() {
- var res;
- while (null !== (res = r.read(readSize++))) {
- reads.push(res.toString());
- }
- r.once('readable', flow);
- }
-
- flow();
-});
-
-test('pipe', function(t) {
- var r = new TestReader(5);
-
- var expect = [ 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx' ]
-
- var w = new TestWriter;
- var flush = true;
-
- w.on('end', function(received) {
- t.same(received, expect);
- t.end();
- });
-
- r.pipe(w);
-});
-
-
-
-[1,2,3,4,5,6,7,8,9].forEach(function(SPLIT) {
- test('unpipe', function(t) {
- var r = new TestReader(5);
-
- // unpipe after 3 writes, then write to another stream instead.
- var expect = [ 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx' ];
- expect = [ expect.slice(0, SPLIT), expect.slice(SPLIT) ];
-
- var w = [ new TestWriter(), new TestWriter() ];
-
- var writes = SPLIT;
- w[0].on('write', function() {
- if (--writes === 0) {
- r.unpipe();
- t.equal(r._readableState.pipes, null);
- w[0].end();
- r.pipe(w[1]);
- t.equal(r._readableState.pipes, w[1]);
- }
- });
-
- var ended = 0;
-
- var ended0 = false;
- var ended1 = false;
- w[0].on('end', function(results) {
- t.equal(ended0, false);
- ended0 = true;
- ended++;
- t.same(results, expect[0]);
- });
-
- w[1].on('end', function(results) {
- t.equal(ended1, false);
- ended1 = true;
- ended++;
- t.equal(ended, 2);
- t.same(results, expect[1]);
- t.end();
- });
-
- r.pipe(w[0]);
- });
-});
-
-
-// both writers should get the same exact data.
-test('multipipe', function(t) {
- var r = new TestReader(5);
- var w = [ new TestWriter, new TestWriter ];
-
- var expect = [ 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx' ];
-
- var c = 2;
- w[0].on('end', function(received) {
- t.same(received, expect, 'first');
- if (--c === 0) t.end();
- });
- w[1].on('end', function(received) {
- t.same(received, expect, 'second');
- if (--c === 0) t.end();
- });
-
- r.pipe(w[0]);
- r.pipe(w[1]);
-});
-
-
-[1,2,3,4,5,6,7,8,9].forEach(function(SPLIT) {
- test('multi-unpipe', function(t) {
- var r = new TestReader(5);
-
- // unpipe after 3 writes, then write to another stream instead.
- var expect = [ 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx' ];
- expect = [ expect.slice(0, SPLIT), expect.slice(SPLIT) ];
-
- var w = [ new TestWriter(), new TestWriter(), new TestWriter() ];
-
- var writes = SPLIT;
- w[0].on('write', function() {
- if (--writes === 0) {
- r.unpipe();
- w[0].end();
- r.pipe(w[1]);
- }
- });
-
- var ended = 0;
-
- w[0].on('end', function(results) {
- ended++;
- t.same(results, expect[0]);
- });
-
- w[1].on('end', function(results) {
- ended++;
- t.equal(ended, 2);
- t.same(results, expect[1]);
- t.end();
- });
-
- r.pipe(w[0]);
- r.pipe(w[2]);
- });
-});
-
-test('back pressure respected', function (t) {
- function noop() {}
-
- var r = new R({ objectMode: true });
- r._read = noop;
- var counter = 0;
- r.push(["one"]);
- r.push(["two"]);
- r.push(["three"]);
- r.push(["four"]);
- r.push(null);
-
- var w1 = new R();
- w1.write = function (chunk) {
- assert.equal(chunk[0], "one");
- w1.emit("close");
- process.nextTick(function () {
- r.pipe(w2);
- r.pipe(w3);
- })
- };
- w1.end = noop;
-
- r.pipe(w1);
-
- var expected = ["two", "two", "three", "three", "four", "four"];
-
- var w2 = new R();
- w2.write = function (chunk) {
- assert.equal(chunk[0], expected.shift());
- assert.equal(counter, 0);
-
- counter++;
-
- if (chunk[0] === "four") {
- return true;
- }
-
- setTimeout(function () {
- counter--;
- w2.emit("drain");
- }, 10);
-
- return false;
- }
- w2.end = noop;
-
- var w3 = new R();
- w3.write = function (chunk) {
- assert.equal(chunk[0], expected.shift());
- assert.equal(counter, 1);
-
- counter++;
-
- if (chunk[0] === "four") {
- return true;
- }
-
- setTimeout(function () {
- counter--;
- w3.emit("drain");
- }, 50);
-
- return false;
- };
- w3.end = function () {
- assert.equal(counter, 2);
- assert.equal(expected.length, 0);
- t.end();
- };
-});
-
-test('read(0) for ended streams', function (t) {
- var r = new R();
- var written = false;
- var ended = false;
- r._read = function (n) {};
-
- r.push(new Buffer("foo"));
- r.push(null);
-
- var v = r.read(0);
-
- assert.equal(v, null);
-
- var w = new R();
-
- w.write = function (buffer) {
- written = true;
- assert.equal(ended, false);
- assert.equal(buffer.toString(), "foo")
- };
-
- w.end = function () {
- ended = true;
- assert.equal(written, true);
- t.end();
- };
-
- r.pipe(w);
-})
-
-test('sync _read ending', function (t) {
- var r = new R();
- var called = false;
- r._read = function (n) {
- r.push(null);
- };
-
- r.once('end', function () {
- called = true;
- })
-
- r.read();
-
- process.nextTick(function () {
- assert.equal(called, true);
- t.end();
- })
-});
-
-test('adding readable triggers data flow', function(t) {
- var r = new R({ highWaterMark: 5 });
- var onReadable = false;
- var readCalled = 0;
-
- r._read = function(n) {
- if (readCalled++ === 2)
- r.push(null);
- else
- r.push(new Buffer('asdf'));
- };
-
- var called = false;
- r.on('readable', function() {
- onReadable = true;
- r.read();
- });
-
- r.on('end', function() {
- t.equal(readCalled, 3);
- t.ok(onReadable);
- t.end();
- });
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-
-var common = require('../common.js');
-var R = require('../../lib/_stream_readable');
-var assert = require('assert');
-
-var util = require('util');
-var EE = require('events').EventEmitter;
-
-var ondataCalled = 0;
-
-function TestReader() {
- R.apply(this);
- this._buffer = new Buffer(100);
- this._buffer.fill('x');
-
- this.on('data', function() {
- ondataCalled++;
- });
-}
-
-util.inherits(TestReader, R);
-
-TestReader.prototype._read = function(n) {
- this.push(this._buffer);
- this._buffer = new Buffer(0);
-};
-
-var reader = new TestReader();
-assert.equal(ondataCalled, 1);
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var common = require('../common.js');
-var stream = require('../../readable');
-var Buffer = require('buffer').Buffer;
-
-var r = new stream.Readable();
-r._read = function(size) {
- r.push(new Buffer(size));
-};
-
-var w = new stream.Writable();
-w._write = function(data, encoding, cb) {
- cb(null);
-};
-
-r.pipe(w);
-
-// This might sound unrealistic, but it happens in net.js. When
-// `socket.allowHalfOpen === false`, EOF will cause `.destroySoon()` call which
-// ends the writable side of net.Socket.
-w.end();
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var common = require('../common.js');
-var assert = require('assert');
-
-// If everything aligns so that you do a read(n) of exactly the
-// remaining buffer, then make sure that 'end' still emits.
-
-var READSIZE = 100;
-var PUSHSIZE = 20;
-var PUSHCOUNT = 1000;
-var HWM = 50;
-
-var Readable = require('../../readable').Readable;
-var r = new Readable({
- highWaterMark: HWM
-});
-var rs = r._readableState;
-
-r._read = push;
-
-r.on('readable', function() {
- console.error('>> readable');
- do {
- console.error(' > read(%d)', READSIZE);
- var ret = r.read(READSIZE);
- console.error(' < %j (%d remain)', ret && ret.length, rs.length);
- } while (ret && ret.length === READSIZE);
-
- console.error('<< after read()',
- ret && ret.length,
- rs.needReadable,
- rs.length);
-});
-
-var endEmitted = false;
-r.on('end', function() {
- endEmitted = true;
- console.error('end');
-});
-
-var pushes = 0;
-function push() {
- if (pushes > PUSHCOUNT)
- return;
-
- if (pushes++ === PUSHCOUNT) {
- console.error(' push(EOF)');
- return r.push(null);
- }
-
- console.error(' push #%d', pushes);
- if (r.push(new Buffer(PUSHSIZE)))
- setTimeout(push);
-}
-
-// start the flow
-var ret = r.read(0);
-
-process.on('exit', function() {
- assert.equal(pushes, PUSHCOUNT + 1);
- assert(endEmitted);
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-
-var common = require('../common.js');
-var Readable = require('../../lib/_stream_readable');
-var Writable = require('../../lib/_stream_writable');
-var assert = require('assert');
-
-// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
-
-function test(name, fn) {
- count++;
- tests.push([name, fn]);
-}
-
-function run() {
- var next = tests.shift();
- if (!next)
- return console.error('ok');
-
- var name = next[0];
- var fn = next[1];
- console.log('# %s', name);
- fn({
- same: assert.deepEqual,
- equal: assert.equal,
- end: function() {
- count--;
- run();
- }
- });
-}
-
-// ensure all tests have run
-process.on('exit', function() {
- assert.equal(count, 0);
-});
-
-process.nextTick(run);
-
-function toArray(callback) {
- var stream = new Writable({ objectMode: true });
- var list = [];
- stream.write = function(chunk) {
- list.push(chunk);
- };
-
- stream.end = function() {
- callback(list);
- };
-
- return stream;
-}
-
-function fromArray(list) {
- var r = new Readable({ objectMode: true });
- r._read = noop;
- list.forEach(function(chunk) {
- r.push(chunk);
- });
- r.push(null);
-
- return r;
-}
-
-function noop() {}
-
-test('can read objects from stream', function(t) {
- var r = fromArray([{ one: '1'}, { two: '2' }]);
-
- var v1 = r.read();
- var v2 = r.read();
- var v3 = r.read();
-
- assert.deepEqual(v1, { one: '1' });
- assert.deepEqual(v2, { two: '2' });
- assert.deepEqual(v3, null);
-
- t.end();
-});
-
-test('can pipe objects into stream', function(t) {
- var r = fromArray([{ one: '1'}, { two: '2' }]);
-
- r.pipe(toArray(function(list) {
- assert.deepEqual(list, [
- { one: '1' },
- { two: '2' }
- ]);
-
- t.end();
- }));
-});
-
-test('read(n) is ignored', function(t) {
- var r = fromArray([{ one: '1'}, { two: '2' }]);
-
- var value = r.read(2);
-
- assert.deepEqual(value, { one: '1' });
-
- t.end();
-});
-
-test('can read objects from _read (sync)', function(t) {
- var r = new Readable({ objectMode: true });
- var list = [{ one: '1'}, { two: '2' }];
- r._read = function(n) {
- var item = list.shift();
- r.push(item || null);
- };
-
- r.pipe(toArray(function(list) {
- assert.deepEqual(list, [
- { one: '1' },
- { two: '2' }
- ]);
-
- t.end();
- }));
-});
-
-test('can read objects from _read (async)', function(t) {
- var r = new Readable({ objectMode: true });
- var list = [{ one: '1'}, { two: '2' }];
- r._read = function(n) {
- var item = list.shift();
- process.nextTick(function() {
- r.push(item || null);
- });
- };
-
- r.pipe(toArray(function(list) {
- assert.deepEqual(list, [
- { one: '1' },
- { two: '2' }
- ]);
-
- t.end();
- }));
-});
-
-test('can read strings as objects', function(t) {
- var r = new Readable({
- objectMode: true
- });
- r._read = noop;
- var list = ['one', 'two', 'three'];
- list.forEach(function(str) {
- r.push(str);
- });
- r.push(null);
-
- r.pipe(toArray(function(array) {
- assert.deepEqual(array, list);
-
- t.end();
- }));
-});
-
-test('read(0) for object streams', function(t) {
- var r = new Readable({
- objectMode: true
- });
- r._read = noop;
-
- r.push('foobar');
- r.push(null);
-
- var v = r.read(0);
-
- r.pipe(toArray(function(array) {
- assert.deepEqual(array, ['foobar']);
-
- t.end();
- }));
-});
-
-test('falsey values', function(t) {
- var r = new Readable({
- objectMode: true
- });
- r._read = noop;
-
- r.push(false);
- r.push(0);
- r.push('');
- r.push(null);
-
- r.pipe(toArray(function(array) {
- assert.deepEqual(array, [false, 0, '']);
-
- t.end();
- }));
-});
-
-test('high watermark _read', function(t) {
- var r = new Readable({
- highWaterMark: 6,
- objectMode: true
- });
- var calls = 0;
- var list = ['1', '2', '3', '4', '5', '6', '7', '8'];
-
- r._read = function(n) {
- calls++;
- };
-
- list.forEach(function(c) {
- r.push(c);
- });
-
- var v = r.read();
-
- assert.equal(calls, 0);
- assert.equal(v, '1');
-
- var v2 = r.read();
-
- assert.equal(calls, 1);
- assert.equal(v2, '2');
-
- t.end();
-});
-
-test('high watermark push', function(t) {
- var r = new Readable({
- highWaterMark: 6,
- objectMode: true
- });
- r._read = function(n) {};
- for (var i = 0; i < 6; i++) {
- var bool = r.push(i);
- assert.equal(bool, i === 5 ? false : true);
- }
-
- t.end();
-});
-
-test('can write objects to stream', function(t) {
- var w = new Writable({ objectMode: true });
-
- w._write = function(chunk, encoding, cb) {
- assert.deepEqual(chunk, { foo: 'bar' });
- cb();
- };
-
- w.on('finish', function() {
- t.end();
- });
-
- w.write({ foo: 'bar' });
- w.end();
-});
-
-test('can write multiple objects to stream', function(t) {
- var w = new Writable({ objectMode: true });
- var list = [];
-
- w._write = function(chunk, encoding, cb) {
- list.push(chunk);
- cb();
- };
-
- w.on('finish', function() {
- assert.deepEqual(list, [0, 1, 2, 3, 4]);
-
- t.end();
- });
-
- w.write(0);
- w.write(1);
- w.write(2);
- w.write(3);
- w.write(4);
- w.end();
-});
-
-test('can write strings as objects', function(t) {
- var w = new Writable({
- objectMode: true
- });
- var list = [];
-
- w._write = function(chunk, encoding, cb) {
- list.push(chunk);
- process.nextTick(cb);
- };
-
- w.on('finish', function() {
- assert.deepEqual(list, ['0', '1', '2', '3', '4']);
-
- t.end();
- });
-
- w.write('0');
- w.write('1');
- w.write('2');
- w.write('3');
- w.write('4');
- w.end();
-});
-
-test('buffers finish until cb is called', function(t) {
- var w = new Writable({
- objectMode: true
- });
- var called = false;
-
- w._write = function(chunk, encoding, cb) {
- assert.equal(chunk, 'foo');
-
- process.nextTick(function() {
- called = true;
- cb();
- });
- };
-
- w.on('finish', function() {
- assert.equal(called, true);
-
- t.end();
- });
-
- w.write('foo');
- w.end();
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var common = require('../common');
-var assert = require('assert');
-var stream = require('../../readable');
-
-(function testErrorListenerCatches() {
- var count = 1000;
-
- var source = new stream.Readable();
- source._read = function(n) {
- n = Math.min(count, n);
- count -= n;
- source.push(new Buffer(n));
- };
-
- var unpipedDest;
- source.unpipe = function(dest) {
- unpipedDest = dest;
- stream.Readable.prototype.unpipe.call(this, dest);
- };
-
- var dest = new stream.Writable();
- dest._write = function(chunk, encoding, cb) {
- cb();
- };
-
- source.pipe(dest);
-
- var gotErr = null;
- dest.on('error', function(err) {
- gotErr = err;
- });
-
- var unpipedSource;
- dest.on('unpipe', function(src) {
- unpipedSource = src;
- });
-
- var err = new Error('This stream turned into bacon.');
- dest.emit('error', err);
- assert.strictEqual(gotErr, err);
- assert.strictEqual(unpipedSource, source);
- assert.strictEqual(unpipedDest, dest);
-})();
-
-(function testErrorWithoutListenerThrows() {
- var count = 1000;
-
- var source = new stream.Readable();
- source._read = function(n) {
- n = Math.min(count, n);
- count -= n;
- source.push(new Buffer(n));
- };
-
- var unpipedDest;
- source.unpipe = function(dest) {
- unpipedDest = dest;
- stream.Readable.prototype.unpipe.call(this, dest);
- };
-
- var dest = new stream.Writable();
- dest._write = function(chunk, encoding, cb) {
- cb();
- };
-
- source.pipe(dest);
-
- var unpipedSource;
- dest.on('unpipe', function(src) {
- unpipedSource = src;
- });
-
- var err = new Error('This stream turned into bacon.');
-
- var gotErr = null;
- try {
- dest.emit('error', err);
- } catch (e) {
- gotErr = e;
- }
- assert.strictEqual(gotErr, err);
- assert.strictEqual(unpipedSource, source);
- assert.strictEqual(unpipedDest, dest);
-})();
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var common = require('../common.js');
-var stream = require('../../readable');
-var Readable = stream.Readable;
-var Writable = stream.Writable;
-var assert = require('assert');
-
-var util = require('util');
-var EE = require('events').EventEmitter;
-
-
-// a mock thing a bit like the net.Socket/tcp_wrap.handle interaction
-
-var stream = new Readable({
- highWaterMark: 16,
- encoding: 'utf8'
-});
-
-var source = new EE;
-
-stream._read = function() {
- console.error('stream._read');
- readStart();
-};
-
-var ended = false;
-stream.on('end', function() {
- ended = true;
-});
-
-source.on('data', function(chunk) {
- var ret = stream.push(chunk);
- console.error('data', stream._readableState.length);
- if (!ret)
- readStop();
-});
-
-source.on('end', function() {
- stream.push(null);
-});
-
-var reading = false;
-
-function readStart() {
- console.error('readStart');
- reading = true;
-}
-
-function readStop() {
- console.error('readStop');
- reading = false;
- process.nextTick(function() {
- var r = stream.read();
- if (r !== null)
- writer.write(r);
- });
-}
-
-var writer = new Writable({
- decodeStrings: false
-});
-
-var written = [];
-
-var expectWritten =
- [ 'asdfgasdfgasdfgasdfg',
- 'asdfgasdfgasdfgasdfg',
- 'asdfgasdfgasdfgasdfg',
- 'asdfgasdfgasdfgasdfg',
- 'asdfgasdfgasdfgasdfg',
- 'asdfgasdfgasdfgasdfg' ];
-
-writer._write = function(chunk, encoding, cb) {
- console.error('WRITE %s', chunk);
- written.push(chunk);
- process.nextTick(cb);
-};
-
-writer.on('finish', finish);
-
-
-// now emit some chunks.
-
-var chunk = "asdfg";
-
-var set = 0;
-readStart();
-data();
-function data() {
- assert(reading);
- source.emit('data', chunk);
- assert(reading);
- source.emit('data', chunk);
- assert(reading);
- source.emit('data', chunk);
- assert(reading);
- source.emit('data', chunk);
- assert(!reading);
- if (set++ < 5)
- setTimeout(data, 10);
- else
- end();
-}
-
-function finish() {
- console.error('finish');
- assert.deepEqual(written, expectWritten);
- console.log('ok');
-}
-
-function end() {
- source.emit('end');
- assert(!reading);
- writer.end(stream.read());
- setTimeout(function() {
- assert(ended);
- });
-}
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var common = require('../common');
-var assert = require('assert');
-var Readable = require('../../readable').Readable;
-var r = new Readable();
-var N = 256 * 1024;
-
-// Go ahead and allow the pathological case for this test.
-// Yes, it's an infinite loop, that's the point.
-process.maxTickDepth = N + 2;
-
-var reads = 0;
-r._read = function(n) {
- var chunk = reads++ === N ? null : new Buffer(1);
- r.push(chunk);
-};
-
-r.on('readable', function onReadable() {
- if (!(r._readableState.length % 256))
- console.error('readable', r._readableState.length);
- r.read(N * 2);
-});
-
-var ended = false;
-r.on('end', function onEnd() {
- ended = true;
-});
-
-r.read(0);
-
-process.on('exit', function() {
- assert(ended);
- console.log('ok');
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var common = require('../common');
-var assert = require('assert');
-
-var Readable = require('../../readable').Readable;
-
-test1();
-if (!/^v0\.[0-8]\./.test(process.version))
- test2();
-
-function test1() {
- var r = new Readable();
-
- // should not end when we get a Buffer(0) or '' as the _read result
- // that just means that there is *temporarily* no data, but to go
- // ahead and try again later.
- //
- // note that this is very unusual. it only works for crypto streams
- // because the other side of the stream will call read(0) to cycle
- // data through openssl. that's why we set the timeouts to call
- // r.read(0) again later, otherwise there is no more work being done
- // and the process just exits.
-
- var buf = new Buffer(5);
- buf.fill('x');
- var reads = 5;
- r._read = function(n) {
- switch (reads--) {
- case 0:
- return r.push(null); // EOF
- case 1:
- return r.push(buf);
- case 2:
- setTimeout(r.read.bind(r, 0), 10);
- return r.push(new Buffer(0)); // Not-EOF!
- case 3:
- setTimeout(r.read.bind(r, 0), 10);
- return process.nextTick(function() {
- return r.push(new Buffer(0));
- });
- case 4:
- setTimeout(r.read.bind(r, 0), 10);
- return setTimeout(function() {
- return r.push(new Buffer(0));
- });
- case 5:
- return setTimeout(function() {
- return r.push(buf);
- });
- default:
- throw new Error('unreachable');
- }
- };
-
- var results = [];
- function flow() {
- var chunk;
- while (null !== (chunk = r.read()))
- results.push(chunk + '');
- }
- r.on('readable', flow);
- r.on('end', function() {
- results.push('EOF');
- });
- flow();
-
- process.on('exit', function() {
- assert.deepEqual(results, [ 'xxxxx', 'xxxxx', 'EOF' ]);
- console.log('ok');
- });
-}
-
-function test2() {
- var r = new Readable({ encoding: 'base64' });
- var reads = 5;
- r._read = function(n) {
- if (!reads--)
- return r.push(null); // EOF
- else
- return r.push(new Buffer('x'));
- };
-
- var results = [];
- function flow() {
- var chunk;
- while (null !== (chunk = r.read()))
- results.push(chunk + '');
- }
- r.on('readable', flow);
- r.on('end', function() {
- results.push('EOF');
- });
- flow();
-
- process.on('exit', function() {
- assert.deepEqual(results, [ 'eHh4', 'eHg=', 'EOF' ]);
- console.log('ok');
- });
-}
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var assert = require('assert');
-var common = require('../common.js');
-var fromList = require('../../lib/_stream_readable')._fromList;
-
-// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
-
-function test(name, fn) {
- count++;
- tests.push([name, fn]);
-}
-
-function run() {
- var next = tests.shift();
- if (!next)
- return console.error('ok');
-
- var name = next[0];
- var fn = next[1];
- console.log('# %s', name);
- fn({
- same: assert.deepEqual,
- equal: assert.equal,
- end: function () {
- count--;
- run();
- }
- });
-}
-
-// ensure all tests have run
-process.on("exit", function () {
- assert.equal(count, 0);
-});
-
-process.nextTick(run);
-
-
-
-test('buffers', function(t) {
- // have a length
- var len = 16;
- var list = [ new Buffer('foog'),
- new Buffer('bark'),
- new Buffer('bazy'),
- new Buffer('kuel') ];
-
- // read more than the first element.
- var ret = fromList(6, { buffer: list, length: 16 });
- t.equal(ret.toString(), 'foogba');
-
- // read exactly the first element.
- ret = fromList(2, { buffer: list, length: 10 });
- t.equal(ret.toString(), 'rk');
-
- // read less than the first element.
- ret = fromList(2, { buffer: list, length: 8 });
- t.equal(ret.toString(), 'ba');
-
- // read more than we have.
- ret = fromList(100, { buffer: list, length: 6 });
- t.equal(ret.toString(), 'zykuel');
-
- // all consumed.
- t.same(list, []);
-
- t.end();
-});
-
-test('strings', function(t) {
- // have a length
- var len = 16;
- var list = [ 'foog',
- 'bark',
- 'bazy',
- 'kuel' ];
-
- // read more than the first element.
- var ret = fromList(6, { buffer: list, length: 16, decoder: true });
- t.equal(ret, 'foogba');
-
- // read exactly the first element.
- ret = fromList(2, { buffer: list, length: 10, decoder: true });
- t.equal(ret, 'rk');
-
- // read less than the first element.
- ret = fromList(2, { buffer: list, length: 8, decoder: true });
- t.equal(ret, 'ba');
-
- // read more than we have.
- ret = fromList(100, { buffer: list, length: 6, decoder: true });
- t.equal(ret, 'zykuel');
-
- // all consumed.
- t.same(list, []);
-
- t.end();
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var common = require('../common');
-var assert = require('assert');
-
-var Stream = require('../../readable');
-var Readable = Stream.Readable;
-
-var r = new Readable();
-var N = 256;
-var reads = 0;
-r._read = function(n) {
- return r.push(++reads === N ? null : new Buffer(1));
-};
-
-var rended = false;
-r.on('end', function() {
- rended = true;
-});
-
-var w = new Stream();
-w.writable = true;
-var writes = 0;
-var buffered = 0;
-w.write = function(c) {
- writes += c.length;
- buffered += c.length;
- process.nextTick(drain);
- return false;
-};
-
-function drain() {
- assert(buffered <= 2);
- buffered = 0;
- w.emit('drain');
-}
-
-
-var wended = false;
-w.end = function() {
- wended = true;
-};
-
-// Just for kicks, let's mess with the drain count.
-// This verifies that even if it gets negative in the
-// pipe() cleanup function, we'll still function properly.
-r.on('readable', function() {
- w.emit('drain');
-});
-
-r.pipe(w);
-process.on('exit', function() {
- assert(rended);
- assert(wended);
- console.error('ok');
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var assert = require('assert');
-var common = require('../common.js');
-var Readable = require('../../lib/_stream_readable');
-
-var len = 0;
-var chunks = new Array(10);
-for (var i = 1; i <= 10; i++) {
- chunks[i-1] = new Buffer(i);
- len += i;
-}
-
-var test = new Readable();
-var n = 0;
-test._read = function(size) {
- var chunk = chunks[n++];
- setTimeout(function() {
- test.push(chunk);
- });
-};
-
-test.on('end', thrower);
-function thrower() {
- throw new Error('this should not happen!');
-}
-
-var bytesread = 0;
-test.on('readable', function() {
- var b = len - bytesread - 1;
- var res = test.read(b);
- if (res) {
- bytesread += res.length;
- console.error('br=%d len=%d', bytesread, len);
- setTimeout(next);
- }
- test.read(0);
-});
-test.read(0);
-
-function next() {
- // now let's make 'end' happen
- test.removeListener('end', thrower);
-
- var endEmitted = false;
- process.on('exit', function() {
- assert(endEmitted, 'end should be emitted by now');
- });
- test.on('end', function() {
- endEmitted = true;
- });
-
- // one to get the last byte
- var r = test.read();
- assert(r);
- assert.equal(r.length, 1);
- r = test.read();
- assert.equal(r, null);
-}
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-
-var common = require('../common.js');
-var assert = require('assert');
-var R = require('../../lib/_stream_readable');
-var util = require('util');
-
-// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
-
-function test(name, fn) {
- count++;
- tests.push([name, fn]);
-}
-
-function run() {
- var next = tests.shift();
- if (!next)
- return console.error('ok');
-
- var name = next[0];
- var fn = next[1];
- console.log('# %s', name);
- fn({
- same: assert.deepEqual,
- equal: assert.equal,
- end: function () {
- count--;
- run();
- }
- });
-}
-
-// ensure all tests have run
-process.on("exit", function () {
- assert.equal(count, 0);
-});
-
-process.nextTick(run);
-
-/////
-
-util.inherits(TestReader, R);
-
-function TestReader(n, opts) {
- R.call(this, opts);
-
- this.pos = 0;
- this.len = n || 100;
-}
-
-TestReader.prototype._read = function(n) {
- setTimeout(function() {
-
- if (this.pos >= this.len) {
- return this.push(null);
- }
-
- n = Math.min(n, this.len - this.pos);
- if (n <= 0) {
- return this.push(null);
- }
-
- this.pos += n;
- var ret = new Buffer(n);
- ret.fill('a');
-
- console.log("this.push(ret)", ret)
-
- return this.push(ret);
- }.bind(this), 1);
-};
-
-test('setEncoding utf8', function(t) {
- var tr = new TestReader(100);
- tr.setEncoding('utf8');
- var out = [];
- var expect =
- [ 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa' ];
-
- tr.on('readable', function flow() {
- var chunk;
- while (null !== (chunk = tr.read(10)))
- out.push(chunk);
- });
-
- tr.on('end', function() {
- t.same(out, expect);
- t.end();
- });
-
- // just kick it off.
- tr.emit('readable');
-});
-
-
-test('setEncoding hex', function(t) {
- var tr = new TestReader(100);
- tr.setEncoding('hex');
- var out = [];
- var expect =
- [ '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161' ];
-
- tr.on('readable', function flow() {
- var chunk;
- while (null !== (chunk = tr.read(10)))
- out.push(chunk);
- });
-
- tr.on('end', function() {
- t.same(out, expect);
- t.end();
- });
-
- // just kick it off.
- tr.emit('readable');
-});
-
-test('setEncoding hex with read(13)', function(t) {
- var tr = new TestReader(100);
- tr.setEncoding('hex');
- var out = [];
- var expect =
- [ "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "16161" ];
-
- tr.on('readable', function flow() {
- console.log("readable once")
- var chunk;
- while (null !== (chunk = tr.read(13)))
- out.push(chunk);
- });
-
- tr.on('end', function() {
- console.log("END")
- t.same(out, expect);
- t.end();
- });
-
- // just kick it off.
- tr.emit('readable');
-});
-
-test('encoding: utf8', function(t) {
- var tr = new TestReader(100, { encoding: 'utf8' });
- var out = [];
- var expect =
- [ 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa',
- 'aaaaaaaaaa' ];
-
- tr.on('readable', function flow() {
- var chunk;
- while (null !== (chunk = tr.read(10)))
- out.push(chunk);
- });
-
- tr.on('end', function() {
- t.same(out, expect);
- t.end();
- });
-
- // just kick it off.
- tr.emit('readable');
-});
-
-
-test('encoding: hex', function(t) {
- var tr = new TestReader(100, { encoding: 'hex' });
- var out = [];
- var expect =
- [ '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161',
- '6161616161' ];
-
- tr.on('readable', function flow() {
- var chunk;
- while (null !== (chunk = tr.read(10)))
- out.push(chunk);
- });
-
- tr.on('end', function() {
- t.same(out, expect);
- t.end();
- });
-
- // just kick it off.
- tr.emit('readable');
-});
-
-test('encoding: hex with read(13)', function(t) {
- var tr = new TestReader(100, { encoding: 'hex' });
- var out = [];
- var expect =
- [ "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "1616161616161",
- "6161616161616",
- "16161" ];
-
- tr.on('readable', function flow() {
- var chunk;
- while (null !== (chunk = tr.read(13)))
- out.push(chunk);
- });
-
- tr.on('end', function() {
- t.same(out, expect);
- t.end();
- });
-
- // just kick it off.
- tr.emit('readable');
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var assert = require('assert');
-var common = require('../common.js');
-var PassThrough = require('../../lib/_stream_passthrough');
-var Transform = require('../../lib/_stream_transform');
-
-// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
-
-function test(name, fn) {
- count++;
- tests.push([name, fn]);
-}
-
-function run() {
- var next = tests.shift();
- if (!next)
- return console.error('ok');
-
- var name = next[0];
- var fn = next[1];
- console.log('# %s', name);
- fn({
- same: assert.deepEqual,
- equal: assert.equal,
- ok: assert,
- end: function () {
- count--;
- run();
- }
- });
-}
-
-// ensure all tests have run
-process.on("exit", function () {
- assert.equal(count, 0);
-});
-
-process.nextTick(run);
-
-/////
-
-test('writable side consumption', function(t) {
- var tx = new Transform({
- highWaterMark: 10
- });
-
- var transformed = 0;
- tx._transform = function(chunk, encoding, cb) {
- transformed += chunk.length;
- tx.push(chunk);
- cb();
- };
-
- for (var i = 1; i <= 10; i++) {
- tx.write(new Buffer(i));
- }
- tx.end();
-
- t.equal(tx._readableState.length, 10);
- t.equal(transformed, 10);
- t.equal(tx._transformState.writechunk.length, 5);
- t.same(tx._writableState.buffer.map(function(c) {
- return c.chunk.length;
- }), [6, 7, 8, 9, 10]);
-
- t.end();
-});
-
-test('passthrough', function(t) {
- var pt = new PassThrough();
-
- pt.write(new Buffer('foog'));
- pt.write(new Buffer('bark'));
- pt.write(new Buffer('bazy'));
- pt.write(new Buffer('kuel'));
- pt.end();
-
- t.equal(pt.read(5).toString(), 'foogb');
- t.equal(pt.read(5).toString(), 'arkba');
- t.equal(pt.read(5).toString(), 'zykue');
- t.equal(pt.read(5).toString(), 'l');
- t.end();
-});
-
-test('simple transform', function(t) {
- var pt = new Transform;
- pt._transform = function(c, e, cb) {
- var ret = new Buffer(c.length);
- ret.fill('x');
- pt.push(ret);
- cb();
- };
-
- pt.write(new Buffer('foog'));
- pt.write(new Buffer('bark'));
- pt.write(new Buffer('bazy'));
- pt.write(new Buffer('kuel'));
- pt.end();
-
- t.equal(pt.read(5).toString(), 'xxxxx');
- t.equal(pt.read(5).toString(), 'xxxxx');
- t.equal(pt.read(5).toString(), 'xxxxx');
- t.equal(pt.read(5).toString(), 'x');
- t.end();
-});
-
-test('async passthrough', function(t) {
- var pt = new Transform;
- pt._transform = function(chunk, encoding, cb) {
- setTimeout(function() {
- pt.push(chunk);
- cb();
- }, 10);
- };
-
- pt.write(new Buffer('foog'));
- pt.write(new Buffer('bark'));
- pt.write(new Buffer('bazy'));
- pt.write(new Buffer('kuel'));
- pt.end();
-
- pt.on('finish', function() {
- t.equal(pt.read(5).toString(), 'foogb');
- t.equal(pt.read(5).toString(), 'arkba');
- t.equal(pt.read(5).toString(), 'zykue');
- t.equal(pt.read(5).toString(), 'l');
- t.end();
- });
-});
-
-test('assymetric transform (expand)', function(t) {
- var pt = new Transform;
-
- // emit each chunk 2 times.
- pt._transform = function(chunk, encoding, cb) {
- setTimeout(function() {
- pt.push(chunk);
- setTimeout(function() {
- pt.push(chunk);
- cb();
- }, 10)
- }, 10);
- };
-
- pt.write(new Buffer('foog'));
- pt.write(new Buffer('bark'));
- pt.write(new Buffer('bazy'));
- pt.write(new Buffer('kuel'));
- pt.end();
-
- pt.on('finish', function() {
- t.equal(pt.read(5).toString(), 'foogf');
- t.equal(pt.read(5).toString(), 'oogba');
- t.equal(pt.read(5).toString(), 'rkbar');
- t.equal(pt.read(5).toString(), 'kbazy');
- t.equal(pt.read(5).toString(), 'bazyk');
- t.equal(pt.read(5).toString(), 'uelku');
- t.equal(pt.read(5).toString(), 'el');
- t.end();
- });
-});
-
-test('assymetric transform (compress)', function(t) {
- var pt = new Transform;
-
- // each output is the first char of 3 consecutive chunks,
- // or whatever's left.
- pt.state = '';
-
- pt._transform = function(chunk, encoding, cb) {
- if (!chunk)
- chunk = '';
- var s = chunk.toString();
- setTimeout(function() {
- this.state += s.charAt(0);
- if (this.state.length === 3) {
- pt.push(new Buffer(this.state));
- this.state = '';
- }
- cb();
- }.bind(this), 10);
- };
-
- pt._flush = function(cb) {
- // just output whatever we have.
- pt.push(new Buffer(this.state));
- this.state = '';
- cb();
- };
-
- pt.write(new Buffer('aaaa'));
- pt.write(new Buffer('bbbb'));
- pt.write(new Buffer('cccc'));
- pt.write(new Buffer('dddd'));
- pt.write(new Buffer('eeee'));
- pt.write(new Buffer('aaaa'));
- pt.write(new Buffer('bbbb'));
- pt.write(new Buffer('cccc'));
- pt.write(new Buffer('dddd'));
- pt.write(new Buffer('eeee'));
- pt.write(new Buffer('aaaa'));
- pt.write(new Buffer('bbbb'));
- pt.write(new Buffer('cccc'));
- pt.write(new Buffer('dddd'));
- pt.end();
-
- // 'abcdeabcdeabcd'
- pt.on('finish', function() {
- t.equal(pt.read(5).toString(), 'abcde');
- t.equal(pt.read(5).toString(), 'abcde');
- t.equal(pt.read(5).toString(), 'abcd');
- t.end();
- });
-});
-
-
-test('passthrough event emission', function(t) {
- var pt = new PassThrough();
- var emits = 0;
- pt.on('readable', function() {
- var state = pt._readableState;
- console.error('>>> emit readable %d', emits);
- emits++;
- });
-
- var i = 0;
-
- pt.write(new Buffer('foog'));
-
- console.error('need emit 0');
- pt.write(new Buffer('bark'));
-
- console.error('should have emitted readable now 1 === %d', emits);
- t.equal(emits, 1);
-
- t.equal(pt.read(5).toString(), 'foogb');
- t.equal(pt.read(5) + '', 'null');
-
- console.error('need emit 1');
-
- pt.write(new Buffer('bazy'));
- console.error('should have emitted, but not again');
- pt.write(new Buffer('kuel'));
-
- console.error('should have emitted readable now 2 === %d', emits);
- t.equal(emits, 2);
-
- t.equal(pt.read(5).toString(), 'arkba');
- t.equal(pt.read(5).toString(), 'zykue');
- t.equal(pt.read(5), null);
-
- console.error('need emit 2');
-
- pt.end();
-
- t.equal(emits, 3);
-
- t.equal(pt.read(5).toString(), 'l');
- t.equal(pt.read(5), null);
-
- console.error('should not have emitted again');
- t.equal(emits, 3);
- t.end();
-});
-
-test('passthrough event emission reordered', function(t) {
- var pt = new PassThrough;
- var emits = 0;
- pt.on('readable', function() {
- console.error('emit readable', emits)
- emits++;
- });
-
- pt.write(new Buffer('foog'));
- console.error('need emit 0');
- pt.write(new Buffer('bark'));
- console.error('should have emitted readable now 1 === %d', emits);
- t.equal(emits, 1);
-
- t.equal(pt.read(5).toString(), 'foogb');
- t.equal(pt.read(5), null);
-
- console.error('need emit 1');
- pt.once('readable', function() {
- t.equal(pt.read(5).toString(), 'arkba');
-
- t.equal(pt.read(5), null);
-
- console.error('need emit 2');
- pt.once('readable', function() {
- t.equal(pt.read(5).toString(), 'zykue');
- t.equal(pt.read(5), null);
- pt.once('readable', function() {
- t.equal(pt.read(5).toString(), 'l');
- t.equal(pt.read(5), null);
- t.equal(emits, 4);
- t.end();
- });
- pt.end();
- });
- pt.write(new Buffer('kuel'));
- });
-
- pt.write(new Buffer('bazy'));
-});
-
-test('passthrough facaded', function(t) {
- console.error('passthrough facaded');
- var pt = new PassThrough;
- var datas = [];
- pt.on('data', function(chunk) {
- datas.push(chunk.toString());
- });
-
- pt.on('end', function() {
- t.same(datas, ['foog', 'bark', 'bazy', 'kuel']);
- t.end();
- });
-
- pt.write(new Buffer('foog'));
- setTimeout(function() {
- pt.write(new Buffer('bark'));
- setTimeout(function() {
- pt.write(new Buffer('bazy'));
- setTimeout(function() {
- pt.write(new Buffer('kuel'));
- setTimeout(function() {
- pt.end();
- }, 10);
- }, 10);
- }, 10);
- }, 10);
-});
-
-test('object transform (json parse)', function(t) {
- console.error('json parse stream');
- var jp = new Transform({ objectMode: true });
- jp._transform = function(data, encoding, cb) {
- try {
- jp.push(JSON.parse(data));
- cb();
- } catch (er) {
- cb(er);
- }
- };
-
- // anything except null/undefined is fine.
- // those are "magic" in the stream API, because they signal EOF.
- var objects = [
- { foo: 'bar' },
- 100,
- "string",
- { nested: { things: [ { foo: 'bar' }, 100, "string" ] } }
- ];
-
- var ended = false;
- jp.on('end', function() {
- ended = true;
- });
-
- objects.forEach(function(obj) {
- jp.write(JSON.stringify(obj));
- var res = jp.read();
- t.same(res, obj);
- });
-
- jp.end();
-
- process.nextTick(function() {
- t.ok(ended);
- t.end();
- })
-});
-
-test('object transform (json stringify)', function(t) {
- console.error('json parse stream');
- var js = new Transform({ objectMode: true });
- js._transform = function(data, encoding, cb) {
- try {
- js.push(JSON.stringify(data));
- cb();
- } catch (er) {
- cb(er);
- }
- };
-
- // anything except null/undefined is fine.
- // those are "magic" in the stream API, because they signal EOF.
- var objects = [
- { foo: 'bar' },
- 100,
- "string",
- { nested: { things: [ { foo: 'bar' }, 100, "string" ] } }
- ];
-
- var ended = false;
- js.on('end', function() {
- ended = true;
- });
-
- objects.forEach(function(obj) {
- js.write(obj);
- var res = js.read();
- t.equal(res, JSON.stringify(obj));
- });
-
- js.end();
-
- process.nextTick(function() {
- t.ok(ended);
- t.end();
- })
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-
-var common = require('../common.js');
-var assert = require('assert');
-var stream = require('../../readable');
-var crypto = require('crypto');
-
-var util = require('util');
-
-function TestWriter() {
- stream.Writable.call(this);
-}
-util.inherits(TestWriter, stream.Writable);
-
-TestWriter.prototype._write = function (buffer, encoding, callback) {
- console.log('write called');
- // super slow write stream (callback never called)
-};
-
-var dest = new TestWriter();
-
-function TestReader(id) {
- stream.Readable.call(this);
- this.reads = 0;
-}
-util.inherits(TestReader, stream.Readable);
-
-TestReader.prototype._read = function (size) {
- this.reads += 1;
- this.push(crypto.randomBytes(size));
-};
-
-var src1 = new TestReader();
-var src2 = new TestReader();
-
-src1.pipe(dest);
-
-src1.once('readable', function () {
- process.nextTick(function () {
-
- src2.pipe(dest);
-
- src2.once('readable', function () {
- process.nextTick(function () {
-
- src1.unpipe(dest);
- });
- });
- });
-});
-
-
-process.on('exit', function () {
- assert.equal(src1.reads, 2);
- assert.equal(src2.reads, 2);
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-
-var common = require('../common.js');
-var assert = require('assert');
-var stream = require('../../readable');
-
-var chunk = new Buffer('hallo');
-
-var util = require('util');
-
-function TestWriter() {
- stream.Writable.call(this);
-}
-util.inherits(TestWriter, stream.Writable);
-
-TestWriter.prototype._write = function(buffer, encoding, callback) {
- callback(null);
-};
-
-var dest = new TestWriter();
-
-// Set this high so that we'd trigger a nextTick warning
-// and/or RangeError if we do maybeReadMore wrong.
-function TestReader() {
- stream.Readable.call(this, { highWaterMark: 0x10000 });
-}
-util.inherits(TestReader, stream.Readable);
-
-TestReader.prototype._read = function(size) {
- this.push(chunk);
-};
-
-var src = new TestReader();
-
-for (var i = 0; i < 10; i++) {
- src.pipe(dest);
- src.unpipe(dest);
-}
-
-assert.equal(src.listeners('end').length, 0);
-assert.equal(src.listeners('readable').length, 0);
-
-assert.equal(dest.listeners('unpipe').length, 0);
-assert.equal(dest.listeners('drain').length, 0);
-assert.equal(dest.listeners('error').length, 0);
-assert.equal(dest.listeners('close').length, 0);
-assert.equal(dest.listeners('finish').length, 0);
-
-console.error(src._readableState);
-process.on('exit', function() {
- assert(src._readableState.length >= src._readableState.highWaterMark);
- src._readableState.buffer.length = 0;
- console.error(src._readableState);
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var common = require('../common.js');
-var W = require('../../lib/_stream_writable');
-var D = require('../../lib/_stream_duplex');
-var assert = require('assert');
-
-var util = require('util');
-util.inherits(TestWriter, W);
-
-function TestWriter() {
- W.apply(this, arguments);
- this.buffer = [];
- this.written = 0;
-}
-
-TestWriter.prototype._write = function(chunk, encoding, cb) {
- // simulate a small unpredictable latency
- setTimeout(function() {
- this.buffer.push(chunk.toString());
- this.written += chunk.length;
- cb();
- }.bind(this), Math.floor(Math.random() * 10));
-};
-
-var chunks = new Array(50);
-for (var i = 0; i < chunks.length; i++) {
- chunks[i] = new Array(i + 1).join('x');
-}
-
-// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
-
-function test(name, fn) {
- count++;
- tests.push([name, fn]);
-}
-
-function run() {
- var next = tests.shift();
- if (!next)
- return console.error('ok');
-
- var name = next[0];
- var fn = next[1];
- console.log('# %s', name);
- fn({
- same: assert.deepEqual,
- equal: assert.equal,
- end: function () {
- count--;
- run();
- }
- });
-}
-
-// ensure all tests have run
-process.on("exit", function () {
- assert.equal(count, 0);
-});
-
-process.nextTick(run);
-
-test('write fast', function(t) {
- var tw = new TestWriter({
- highWaterMark: 100
- });
-
- tw.on('finish', function() {
- t.same(tw.buffer, chunks, 'got chunks in the right order');
- t.end();
- });
-
- chunks.forEach(function(chunk) {
- // screw backpressure. Just buffer it all up.
- tw.write(chunk);
- });
- tw.end();
-});
-
-test('write slow', function(t) {
- var tw = new TestWriter({
- highWaterMark: 100
- });
-
- tw.on('finish', function() {
- t.same(tw.buffer, chunks, 'got chunks in the right order');
- t.end();
- });
-
- var i = 0;
- (function W() {
- tw.write(chunks[i++]);
- if (i < chunks.length)
- setTimeout(W, 10);
- else
- tw.end();
- })();
-});
-
-test('write backpressure', function(t) {
- var tw = new TestWriter({
- highWaterMark: 50
- });
-
- var drains = 0;
-
- tw.on('finish', function() {
- t.same(tw.buffer, chunks, 'got chunks in the right order');
- t.equal(drains, 17);
- t.end();
- });
-
- tw.on('drain', function() {
- drains++;
- });
-
- var i = 0;
- (function W() {
- do {
- var ret = tw.write(chunks[i++]);
- } while (ret !== false && i < chunks.length);
-
- if (i < chunks.length) {
- assert(tw._writableState.length >= 50);
- tw.once('drain', W);
- } else {
- tw.end();
- }
- })();
-});
-
-test('write bufferize', function(t) {
- var tw = new TestWriter({
- highWaterMark: 100
- });
-
- var encodings =
- [ 'hex',
- 'utf8',
- 'utf-8',
- 'ascii',
- 'binary',
- 'base64',
- 'ucs2',
- 'ucs-2',
- 'utf16le',
- 'utf-16le',
- undefined ];
-
- tw.on('finish', function() {
- t.same(tw.buffer, chunks, 'got the expected chunks');
- });
-
- chunks.forEach(function(chunk, i) {
- var enc = encodings[ i % encodings.length ];
- chunk = new Buffer(chunk);
- tw.write(chunk.toString(enc), enc);
- });
- t.end();
-});
-
-test('write no bufferize', function(t) {
- var tw = new TestWriter({
- highWaterMark: 100,
- decodeStrings: false
- });
-
- tw._write = function(chunk, encoding, cb) {
- assert(typeof chunk === 'string');
- chunk = new Buffer(chunk, encoding);
- return TestWriter.prototype._write.call(this, chunk, encoding, cb);
- };
-
- var encodings =
- [ 'hex',
- 'utf8',
- 'utf-8',
- 'ascii',
- 'binary',
- 'base64',
- 'ucs2',
- 'ucs-2',
- 'utf16le',
- 'utf-16le',
- undefined ];
-
- tw.on('finish', function() {
- t.same(tw.buffer, chunks, 'got the expected chunks');
- });
-
- chunks.forEach(function(chunk, i) {
- var enc = encodings[ i % encodings.length ];
- chunk = new Buffer(chunk);
- tw.write(chunk.toString(enc), enc);
- });
- t.end();
-});
-
-test('write callbacks', function (t) {
- var callbacks = chunks.map(function(chunk, i) {
- return [i, function(er) {
- callbacks._called[i] = chunk;
- }];
- }).reduce(function(set, x) {
- set['callback-' + x[0]] = x[1];
- return set;
- }, {});
- callbacks._called = [];
-
- var tw = new TestWriter({
- highWaterMark: 100
- });
-
- tw.on('finish', function() {
- process.nextTick(function() {
- t.same(tw.buffer, chunks, 'got chunks in the right order');
- t.same(callbacks._called, chunks, 'called all callbacks');
- t.end();
- });
- });
-
- chunks.forEach(function(chunk, i) {
- tw.write(chunk, callbacks['callback-' + i]);
- });
- tw.end();
-});
-
-test('end callback', function (t) {
- var tw = new TestWriter();
- tw.end(function () {
- t.end();
- });
-});
-
-test('end callback with chunk', function (t) {
- var tw = new TestWriter();
- tw.end(new Buffer('hello world'), function () {
- t.end();
- });
-});
-
-test('end callback with chunk and encoding', function (t) {
- var tw = new TestWriter();
- tw.end('hello world', 'ascii', function () {
- t.end();
- });
-});
-
-test('end callback after .write() call', function (t) {
- var tw = new TestWriter();
- tw.write(new Buffer('hello world'));
- tw.end(function () {
- t.end();
- });
-});
-
-test('encoding should be ignored for buffers', function(t) {
- var tw = new W();
- var hex = '018b5e9a8f6236ffe30e31baf80d2cf6eb';
- tw._write = function(chunk, encoding, cb) {
- t.equal(chunk.toString('hex'), hex);
- t.end();
- };
- var buf = new Buffer(hex, 'hex');
- tw.write(buf, 'binary');
-});
-
-test('writables are not pipable', function(t) {
- var w = new W();
- w._write = function() {};
- var gotError = false;
- w.on('error', function(er) {
- gotError = true;
- });
- w.pipe(process.stdout);
- assert(gotError);
- t.end();
-});
-
-test('duplexes are pipable', function(t) {
- var d = new D();
- d._read = function() {};
- d._write = function() {};
- var gotError = false;
- d.on('error', function(er) {
- gotError = true;
- });
- d.pipe(process.stdout);
- assert(!gotError);
- t.end();
-});
-
-test('end(chunk) two times is an error', function(t) {
- var w = new W();
- w._write = function() {};
- var gotError = false;
- w.on('error', function(er) {
- gotError = true;
- t.equal(er.message, 'write after end');
- });
- w.end('this is the end');
- w.end('and so is this');
- process.nextTick(function() {
- assert(gotError);
- t.end();
- });
-});
+++ /dev/null
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// 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.
-
-var Transform = require('./lib/_stream_transform.js');
-
-var binding = process.binding('zlib');
-var util = require('util');
-var assert = require('assert').ok;
-
-// zlib doesn't provide these, so kludge them in following the same
-// const naming scheme zlib uses.
-binding.Z_MIN_WINDOWBITS = 8;
-binding.Z_MAX_WINDOWBITS = 15;
-binding.Z_DEFAULT_WINDOWBITS = 15;
-
-// fewer than 64 bytes per chunk is stupid.
-// technically it could work with as few as 8, but even 64 bytes
-// is absurdly low. Usually a MB or more is best.
-binding.Z_MIN_CHUNK = 64;
-binding.Z_MAX_CHUNK = Infinity;
-binding.Z_DEFAULT_CHUNK = (16 * 1024);
-
-binding.Z_MIN_MEMLEVEL = 1;
-binding.Z_MAX_MEMLEVEL = 9;
-binding.Z_DEFAULT_MEMLEVEL = 8;
-
-binding.Z_MIN_LEVEL = -1;
-binding.Z_MAX_LEVEL = 9;
-binding.Z_DEFAULT_LEVEL = binding.Z_DEFAULT_COMPRESSION;
-
-// expose all the zlib constants
-Object.keys(binding).forEach(function(k) {
- if (k.match(/^Z/)) exports[k] = binding[k];
-});
-
-// translation table for return codes.
-exports.codes = {
- Z_OK: binding.Z_OK,
- Z_STREAM_END: binding.Z_STREAM_END,
- Z_NEED_DICT: binding.Z_NEED_DICT,
- Z_ERRNO: binding.Z_ERRNO,
- Z_STREAM_ERROR: binding.Z_STREAM_ERROR,
- Z_DATA_ERROR: binding.Z_DATA_ERROR,
- Z_MEM_ERROR: binding.Z_MEM_ERROR,
- Z_BUF_ERROR: binding.Z_BUF_ERROR,
- Z_VERSION_ERROR: binding.Z_VERSION_ERROR
-};
-
-Object.keys(exports.codes).forEach(function(k) {
- exports.codes[exports.codes[k]] = k;
-});
-
-exports.Deflate = Deflate;
-exports.Inflate = Inflate;
-exports.Gzip = Gzip;
-exports.Gunzip = Gunzip;
-exports.DeflateRaw = DeflateRaw;
-exports.InflateRaw = InflateRaw;
-exports.Unzip = Unzip;
-
-exports.createDeflate = function(o) {
- return new Deflate(o);
-};
-
-exports.createInflate = function(o) {
- return new Inflate(o);
-};
-
-exports.createDeflateRaw = function(o) {
- return new DeflateRaw(o);
-};
-
-exports.createInflateRaw = function(o) {
- return new InflateRaw(o);
-};
-
-exports.createGzip = function(o) {
- return new Gzip(o);
-};
-
-exports.createGunzip = function(o) {
- return new Gunzip(o);
-};
-
-exports.createUnzip = function(o) {
- return new Unzip(o);
-};
-
-
-// Convenience methods.
-// compress/decompress a string or buffer in one step.
-exports.deflate = function(buffer, callback) {
- zlibBuffer(new Deflate(), buffer, callback);
-};
-
-exports.gzip = function(buffer, callback) {
- zlibBuffer(new Gzip(), buffer, callback);
-};
-
-exports.deflateRaw = function(buffer, callback) {
- zlibBuffer(new DeflateRaw(), buffer, callback);
-};
-
-exports.unzip = function(buffer, callback) {
- zlibBuffer(new Unzip(), buffer, callback);
-};
-
-exports.inflate = function(buffer, callback) {
- zlibBuffer(new Inflate(), buffer, callback);
-};
-
-exports.gunzip = function(buffer, callback) {
- zlibBuffer(new Gunzip(), buffer, callback);
-};
-
-exports.inflateRaw = function(buffer, callback) {
- zlibBuffer(new InflateRaw(), buffer, callback);
-};
-
-function zlibBuffer(engine, buffer, callback) {
- var buffers = [];
- var nread = 0;
-
- engine.on('error', onError);
- engine.on('end', onEnd);
-
- engine.end(buffer);
- flow();
-
- function flow() {
- var chunk;
- while (null !== (chunk = engine.read())) {
- buffers.push(chunk);
- nread += chunk.length;
- }
- engine.once('readable', flow);
- }
-
- function onError(err) {
- engine.removeListener('end', onEnd);
- engine.removeListener('readable', flow);
- callback(err);
- }
-
- function onEnd() {
- var buf = Buffer.concat(buffers, nread);
- buffers = [];
- callback(null, buf);
- }
-}
-
-
-// generic zlib
-// minimal 2-byte header
-function Deflate(opts) {
- if (!(this instanceof Deflate)) return new Deflate(opts);
- Zlib.call(this, opts, binding.DEFLATE);
-}
-
-function Inflate(opts) {
- if (!(this instanceof Inflate)) return new Inflate(opts);
- Zlib.call(this, opts, binding.INFLATE);
-}
-
-
-
-// gzip - bigger header, same deflate compression
-function Gzip(opts) {
- if (!(this instanceof Gzip)) return new Gzip(opts);
- Zlib.call(this, opts, binding.GZIP);
-}
-
-function Gunzip(opts) {
- if (!(this instanceof Gunzip)) return new Gunzip(opts);
- Zlib.call(this, opts, binding.GUNZIP);
-}
-
-
-
-// raw - no header
-function DeflateRaw(opts) {
- if (!(this instanceof DeflateRaw)) return new DeflateRaw(opts);
- Zlib.call(this, opts, binding.DEFLATERAW);
-}
-
-function InflateRaw(opts) {
- if (!(this instanceof InflateRaw)) return new InflateRaw(opts);
- Zlib.call(this, opts, binding.INFLATERAW);
-}
-
-
-// auto-detect header.
-function Unzip(opts) {
- if (!(this instanceof Unzip)) return new Unzip(opts);
- Zlib.call(this, opts, binding.UNZIP);
-}
-
-
-// the Zlib class they all inherit from
-// This thing manages the queue of requests, and returns
-// true or false if there is anything in the queue when
-// you call the .write() method.
-
-function Zlib(opts, mode) {
- this._opts = opts = opts || {};
- this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK;
-
- Transform.call(this, opts);
-
- // means a different thing there.
- this._readableState.chunkSize = null;
-
- if (opts.chunkSize) {
- if (opts.chunkSize < exports.Z_MIN_CHUNK ||
- opts.chunkSize > exports.Z_MAX_CHUNK) {
- throw new Error('Invalid chunk size: ' + opts.chunkSize);
- }
- }
-
- if (opts.windowBits) {
- if (opts.windowBits < exports.Z_MIN_WINDOWBITS ||
- opts.windowBits > exports.Z_MAX_WINDOWBITS) {
- throw new Error('Invalid windowBits: ' + opts.windowBits);
- }
- }
-
- if (opts.level) {
- if (opts.level < exports.Z_MIN_LEVEL ||
- opts.level > exports.Z_MAX_LEVEL) {
- throw new Error('Invalid compression level: ' + opts.level);
- }
- }
-
- if (opts.memLevel) {
- if (opts.memLevel < exports.Z_MIN_MEMLEVEL ||
- opts.memLevel > exports.Z_MAX_MEMLEVEL) {
- throw new Error('Invalid memLevel: ' + opts.memLevel);
- }
- }
-
- if (opts.strategy) {
- if (opts.strategy != exports.Z_FILTERED &&
- opts.strategy != exports.Z_HUFFMAN_ONLY &&
- opts.strategy != exports.Z_RLE &&
- opts.strategy != exports.Z_FIXED &&
- opts.strategy != exports.Z_DEFAULT_STRATEGY) {
- throw new Error('Invalid strategy: ' + opts.strategy);
- }
- }
-
- if (opts.dictionary) {
- if (!Buffer.isBuffer(opts.dictionary)) {
- throw new Error('Invalid dictionary: it should be a Buffer instance');
- }
- }
-
- this._binding = new binding.Zlib(mode);
-
- var self = this;
- this._hadError = false;
- this._binding.onerror = function(message, errno) {
- // there is no way to cleanly recover.
- // continuing only obscures problems.
- self._binding = null;
- self._hadError = true;
-
- var error = new Error(message);
- error.errno = errno;
- error.code = exports.codes[errno];
- self.emit('error', error);
- };
-
- this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS,
- opts.level || exports.Z_DEFAULT_COMPRESSION,
- opts.memLevel || exports.Z_DEFAULT_MEMLEVEL,
- opts.strategy || exports.Z_DEFAULT_STRATEGY,
- opts.dictionary);
-
- this._buffer = new Buffer(this._chunkSize);
- this._offset = 0;
- this._closed = false;
-
- this.once('end', this.close);
-}
-
-util.inherits(Zlib, Transform);
-
-Zlib.prototype.reset = function reset() {
- return this._binding.reset();
-};
-
-Zlib.prototype._flush = function(output, callback) {
- var rs = this._readableState;
- var self = this;
- this._transform(null, output, function(er) {
- if (er)
- return callback(er);
-
- // now a weird thing happens... it could be that you called flush
- // but everything had already actually been consumed, but it wasn't
- // enough to get over the Readable class's lowWaterMark.
- // In that case, we emit 'readable' now to make sure it's consumed.
- if (rs.length &&
- rs.length < rs.lowWaterMark &&
- !rs.ended &&
- rs.needReadable)
- self.emit('readable');
-
- callback();
- });
-};
-
-Zlib.prototype.flush = function(callback) {
- var ws = this._writableState;
- var ts = this._transformState;
-
- if (ws.writing) {
- ws.needDrain = true;
- var self = this;
- this.once('drain', function() {
- self._flush(ts.output, callback);
- });
- return;
- }
-
- this._flush(ts.output, callback || function() {});
-};
-
-Zlib.prototype.close = function(callback) {
- if (callback)
- process.nextTick(callback);
-
- if (this._closed)
- return;
-
- this._closed = true;
-
- this._binding.close();
-
- var self = this;
- process.nextTick(function() {
- self.emit('close');
- });
-};
-
-Zlib.prototype._transform = function(chunk, output, cb) {
- var flushFlag;
- var ws = this._writableState;
- var ending = ws.ending || ws.ended;
- var last = ending && (!chunk || ws.length === chunk.length);
-
- if (chunk !== null && !Buffer.isBuffer(chunk))
- return cb(new Error('invalid input'));
-
- // If it's the last chunk, or a final flush, we use the Z_FINISH flush flag.
- // If it's explicitly flushing at some other time, then we use
- // Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression
- // goodness.
- if (last)
- flushFlag = binding.Z_FINISH;
- else if (chunk === null)
- flushFlag = binding.Z_FULL_FLUSH;
- else
- flushFlag = binding.Z_NO_FLUSH;
-
- var availInBefore = chunk && chunk.length;
- var availOutBefore = this._chunkSize - this._offset;
- var inOff = 0;
-
- var req = this._binding.write(flushFlag,
- chunk, // in
- inOff, // in_off
- availInBefore, // in_len
- this._buffer, // out
- this._offset, //out_off
- availOutBefore); // out_len
-
- req.buffer = chunk;
- req.callback = callback;
-
- var self = this;
- function callback(availInAfter, availOutAfter, buffer) {
- if (self._hadError)
- return;
-
- var have = availOutBefore - availOutAfter;
- assert(have >= 0, 'have should not go down');
-
- if (have > 0) {
- var out = self._buffer.slice(self._offset, self._offset + have);
- self._offset += have;
- // serve some output to the consumer.
- output(out);
- }
-
- // exhausted the output buffer, or used all the input create a new one.
- if (availOutAfter === 0 || self._offset >= self._chunkSize) {
- availOutBefore = self._chunkSize;
- self._offset = 0;
- self._buffer = new Buffer(self._chunkSize);
- }
-
- if (availOutAfter === 0) {
- // Not actually done. Need to reprocess.
- // Also, update the availInBefore to the availInAfter value,
- // so that if we have to hit it a third (fourth, etc.) time,
- // it'll have the correct byte counts.
- inOff += (availInBefore - availInAfter);
- availInBefore = availInAfter;
-
- var newReq = self._binding.write(flushFlag,
- chunk,
- inOff,
- availInBefore,
- self._buffer,
- self._offset,
- self._chunkSize);
- newReq.callback = callback; // this same function
- newReq.buffer = chunk;
- return;
- }
-
- // finished with the chunk.
- cb();
- }
-};
-
-util.inherits(Deflate, Zlib);
-util.inherits(Inflate, Zlib);
-util.inherits(Gzip, Zlib);
-util.inherits(Gunzip, Zlib);
-util.inherits(DeflateRaw, Zlib);
-util.inherits(InflateRaw, Zlib);
-util.inherits(Unzip, Zlib);
"bugs": {
"url": "https://github.com/ForbesLindesay/sha/issues"
},
+ "homepage": "https://github.com/ForbesLindesay/sha",
"dependencies": {
"graceful-fs": "2",
"readable-stream": "1.0"
},
"_id": "sha@1.2.3",
- "_from": "sha@latest"
+ "_from": "sha@~1.2.1"
}
{
- "version": "1.3.23",
+ "version": "1.3.24",
"name": "npm",
"publishConfig": {
"proprietary-attribs": false
"mkdirp": "~0.3.5",
"read": "~1.0.4",
"lru-cache": "~2.5.0",
- "node-gyp": "~0.12.0",
+ "node-gyp": "~0.12.2",
"fstream-npm": "~0.1.6",
"uid-number": "0",
"archy": "0",
"chownr": "0",
"npmlog": "0.0.6",
"ansi": "~0.2.1",
- "npm-registry-client": "~0.3.2",
- "read-package-json": "~1.1.4",
+ "npm-registry-client": "~0.3.3",
+ "read-package-json": "~1.1.6",
"read-installed": "~0.2.2",
"glob": "~3.2.6",
"init-package-json": "0.0.14",
"lockfile": "~0.4.0",
"retry": "~0.6.0",
"once": "~1.3.0",
- "npmconf": "~0.1.7",
+ "npmconf": "~0.1.12",
"opener": "~1.3.0",
"chmodr": "~0.1.0",
"cmd-shim": "~1.1.1",
"text-table": "~0.2.0",
"ansicolors": "~0.3.2",
"ansistyles": "~0.1.3",
- "path-is-inside": "~1.0.0"
+ "path-is-inside": "~1.0.0",
+ "columnify": "0.1.2"
},
"bundleDependencies": [
"semver",
"text-table",
"ansicolors",
"ansistyles",
- "path-is-inside"
+ "path-is-inside",
+ "columnify"
],
"devDependencies": {
"ronn": "~0.3.6",
--- /dev/null
+var common = require('../common-tap.js')
+var test = require('tap').test
+var osenv = require('osenv')
+var npm = require.resolve("../../bin/npm-cli.js")
+var node = process.execPath
+var path = require('path')
+var fs = require('fs')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var pkg = path.resolve(__dirname, 'ignore-install-link')
+var spawn = require('child_process').spawn
+var linkDir = path.resolve(osenv.tmpdir(), 'npm-link-issue')
+
+test('ignore-install-link: ignore install if a package is linked', function(t) {
+ setup(function(err) {
+ if (err) {
+ t.ifError(err)
+ t.end()
+ return
+ }
+
+ var p = path.resolve(pkg, 'node_modules', 'npm-link-issue')
+ fs.lstat(p, function(err, s) {
+ t.ifError(err)
+
+ t.ok(true === s.isSymbolicLink(), 'child is a symlink')
+ t.end()
+ })
+ })
+})
+
+test('cleanup', function(t) {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(pkg)
+ rimraf.sync(linkDir)
+ t.end()
+})
+
+
+function setup(cb) {
+ rimraf.sync(linkDir)
+ mkdirp.sync(pkg)
+ mkdirp.sync(path.resolve(pkg, 'cache'))
+ mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ mkdirp.sync(linkDir)
+ fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
+ author: 'Evan Lucas',
+ name: 'ignore-install-link',
+ version: '0.0.0',
+ description: 'Test for ignoring install when a package has been linked',
+ dependencies: {
+ 'npm-link-issue': 'git+https://github.com/lancefisher/npm-link-issue.git#0.0.1'
+ }
+ }), 'utf8')
+ fs.writeFileSync(path.resolve(linkDir, 'package.json'), JSON.stringify({
+ author: 'lancefisher',
+ name: 'npm-link-issue',
+ version: '0.0.1',
+ description: 'Sample Dependency'
+ }), 'utf8')
+
+ clone(cb)
+}
+
+function clone (cb) {
+ var child = createChild(process.cwd(), 'git', ['--git-dir', linkDir, 'init'])
+ child.on('close', function(c) {
+ if (c !== 0)
+ return cb(new Error('Failed to init the git repository'))
+
+ console.log('Successfully inited the git repository')
+ process.chdir(linkDir)
+ performLink(cb)
+ })
+}
+
+function performLink (cb) {
+ var child = createChild(linkDir, node, [npm, 'link', '.'])
+ child.on('close', function(c) {
+ if (c !== 0)
+ return cb(new Error('Failed to link ' + linkDir + ' globally'))
+
+ console.log('Successfully linked ' + linkDir + ' globally')
+ performLink2(cb)
+ })
+}
+
+function performLink2 (cb) {
+ var child = createChild(pkg, node, [npm, 'link', 'npm-link-issue'])
+ child.on('close', function(c) {
+ if (c !== 0)
+ return cb(new Error('Failed to link ' + linkDir + ' to local node_modules'))
+
+ console.log('Successfully linked ' + linkDir + ' to local node_modules')
+ performInstall(cb)
+ })
+}
+
+function performInstall (cb) {
+ var child = createChild(pkg, node, [npm, 'install'])
+ child.on('close', function(c) {
+ if (c !== 0)
+ return cb(new Error('Failed to install'))
+
+ console.log('Successfully installed')
+ cb()
+ })
+}
+
+function createChild (cwd, cmd, args) {
+ var env = {
+ HOME: process.env.HOME,
+ Path: process.env.PATH,
+ PATH: process.env.PATH
+ }
+
+ if (process.platform === "win32")
+ env.npm_config_cache = "%APPDATA%\\npm-cache"
+
+ return spawn(cmd, args, {
+ cwd: cwd,
+ stdio: "inherit",
+ env: env
+ })
+}
test("dicovers new versions in outdated", function (t) {
process.chdir(pkg)
- t.plan(3)
+ t.plan(4)
npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
npm.outdated(function (er, d) {
t.equal('git', d[0][3])
t.equal('git', d[0][4])
t.equal('git://github.com/robertkowalski/foo-private.git', d[0][5])
+ t.equal('git://user:pass@github.com/robertkowalski/foo-private.git', d[1][5])
})
})
})
"version": "0.0.1",
"main": "index.js",
"dependencies": {
- "foo-private": "git://github.com/robertkowalski/foo-private.git"
+ "foo-private": "git://github.com/robertkowalski/foo-private.git",
+ "foo-private-credentials": "git://user:pass@github.com/robertkowalski/foo-private.git"
}
}
, npm = require("../../")
, mr = require("npm-registry-mock")
, path = require("path")
+ , osenv = require("osenv")
, spawn = require('child_process').spawn
, node = process.execPath
, npmc = require.resolve('../../')
- , pkg = __dirname + '/outdated-new-versions'
+ , pkg = path.resolve(__dirname, 'outdated-new-versions')
, args = [ npmc
, 'outdated'
, '--json'
})
function cleanup () {
+ // windows fix for locked files
+ process.chdir(osenv.tmpdir())
rimraf.sync(pkg + "/node_modules")
rimraf.sync(pkg + "/cache")
}
env: env
})
child.stdout.setEncoding('utf8')
- child.stderr.on('data', function(chunk) {
- throw new Error('got stderr data: ' + JSON.stringify('' + chunk))
- })
+ child.stderr.on('data', onerr)
child.stdout.on('data', ondata)
child.on('close', onend)
var c = ''
+ , e = ''
function ondata (chunk) {
c += chunk
}
+ function onerr (chunk) {
+ e += chunk
+ }
function onend () {
+ if (e) {
+ throw new Error('got stderr data: ' + JSON.stringify('' + e))
+ }
c = c.trim()
var regex = new RegExp("" +
"> npm-test-prepublish@1.2.5 prepublish [^\\r\\n]+\\r?\\n" +
--- /dev/null
+var test = require('tap').test
+var path = require('path')
+var npm = path.resolve(__dirname, '../../cli.js')
+var pkg = __dirname + '/scripts-whitespace-windows'
+var tmp = pkg + '/tmp'
+var cache = pkg + '/cache'
+var modules = pkg + '/node_modules'
+var dep = pkg + '/dep'
+
+var mkdirp = require('mkdirp')
+var rimraf = require('rimraf')
+var node = process.execPath
+var spawn = require('child_process').spawn
+
+test('setup', function (t) {
+ mkdirp.sync(cache)
+ mkdirp.sync(tmp)
+ rimraf.sync(modules)
+
+ var env = {
+ npm_config_cache: cache,
+ npm_config_tmp: tmp,
+ npm_config_prefix: pkg,
+ npm_config_global: 'false'
+ }
+
+ var child = spawn(node, [npm, 'i', dep], {
+ cwd: pkg,
+ env: env
+ })
+
+ child.stdout.setEncoding('utf8')
+ child.stderr.on('data', function(chunk) {
+ throw new Error('got stderr data: ' + JSON.stringify('' + chunk))
+ })
+ child.on('close', function () {
+ t.end()
+ })
+})
+
+test('test', function (t) {
+
+ var child = spawn(node, [npm, 'run', 'foo'], {
+ cwd: pkg,
+ env: process.env
+ })
+
+ child.stdout.setEncoding('utf8')
+ child.stderr.on('data', function(chunk) {
+ throw new Error('got stderr data: ' + JSON.stringify('' + chunk))
+ })
+ child.stdout.on('data', ondata)
+ child.on('close', onend)
+ var c = ''
+ function ondata (chunk) {
+ c += chunk
+ }
+ function onend () {
+ c = c.trim()
+
+ t.ok(/npm-test-fine/.test(c))
+ t.end()
+ }
+})
+
+test('cleanup', function (t) {
+ rimraf.sync(cache)
+ rimraf.sync(tmp)
+ rimraf.sync(modules)
+ t.end()
+})
--- /dev/null
+#!/usr/bin/env node
+
+if (process.argv.length === 8)
+ console.log('npm-test-fine')
--- /dev/null
+{
+ "name": "scripts-whitespace-windows-dep",
+ "version": "0.0.1",
+ "bin": [ "bin/foo" ],
+ "repository": "git://github.com/robertkowalski/bogusfixture"
+}
--- /dev/null
+{
+ "name": "scripts-whitespace-windows",
+ "scripts": {
+ "foo": "foo --title \"Analysis of\" --recurse -d report src"
+ },
+ "description": "a test",
+ "repository": "git://github.com/robertkowalski/bogus",
+ "dependencies": {
+ "scripts-whitespace-windows-dep": "0.0.1"
+ }
+}
function run (command, t, parse) {
var c = ''
+ , e = ''
, node = process.execPath
, child = spawn(node, [npm, command], {
cwd: pkg
})
child.stderr.on('data', function (chunk) {
- throw new Error('npm ' + command + ' stderr: ' + chunk.toString())
+ e += chunk
})
child.stdout.on('data', function (chunk) {
})
child.stdout.on('end', function () {
+ if (e) {
+ throw new Error('npm ' + command + ' stderr: ' + e.toString())
+ }
if (parse) {
// custom parsing function
c = parse(c)