mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
Changes
This commit is contained in:
2
node_modules/pkginfo/.npmignore
generated
vendored
Normal file
2
node_modules/pkginfo/.npmignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
npm-debug.log
|
19
node_modules/pkginfo/LICENSE
generated
vendored
Normal file
19
node_modules/pkginfo/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010 Charlie Robbins.
|
||||
|
||||
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.
|
86
node_modules/pkginfo/README.md
generated
vendored
Normal file
86
node_modules/pkginfo/README.md
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
# node-pkginfo
|
||||
|
||||
An easy way to expose properties on a module from a package.json
|
||||
|
||||
## Installation
|
||||
|
||||
### Installing npm (node package manager)
|
||||
```
|
||||
curl http://npmjs.org/install.sh | sh
|
||||
```
|
||||
|
||||
### Installing pkginfo
|
||||
```
|
||||
[sudo] npm install pkginfo
|
||||
```
|
||||
|
||||
## Motivation
|
||||
How often when writing node.js modules have you written the following line(s) of code?
|
||||
|
||||
* Hard code your version string into your code
|
||||
|
||||
``` js
|
||||
exports.version = '0.1.0';
|
||||
```
|
||||
|
||||
* Programmatically expose the version from the package.json
|
||||
|
||||
``` js
|
||||
exports.version = require('/path/to/package.json').version;
|
||||
```
|
||||
|
||||
In other words, how often have you wanted to expose basic information from your package.json onto your module programmatically? **WELL NOW YOU CAN!**
|
||||
|
||||
## Usage
|
||||
|
||||
Using `pkginfo` is idiot-proof, just require and invoke it.
|
||||
|
||||
``` js
|
||||
var pkginfo = require('pkginfo')(module);
|
||||
|
||||
console.dir(module.exports);
|
||||
```
|
||||
|
||||
By invoking the `pkginfo` module all of the properties in your `package.json` file will be automatically exposed on the callee module (i.e. the parent module of `pkginfo`).
|
||||
|
||||
Here's a sample of the output:
|
||||
|
||||
```
|
||||
{ name: 'simple-app',
|
||||
description: 'A test fixture for pkginfo',
|
||||
version: '0.1.0',
|
||||
author: 'Charlie Robbins <charlie.robbins@gmail.com>',
|
||||
keywords: [ 'test', 'fixture' ],
|
||||
main: './index.js',
|
||||
scripts: { test: 'vows test/*-test.js --spec' },
|
||||
engines: { node: '>= 0.4.0' } }
|
||||
```
|
||||
|
||||
### Expose specific properties
|
||||
If you don't want to expose **all** properties on from your `package.json` on your module then simple pass those properties to the `pkginfo` function:
|
||||
|
||||
``` js
|
||||
var pkginfo = require('pkginfo')(module, 'version', 'author');
|
||||
|
||||
console.dir(module.exports);
|
||||
```
|
||||
|
||||
```
|
||||
{ version: '0.1.0',
|
||||
author: 'Charlie Robbins <charlie.robbins@gmail.com>' }
|
||||
```
|
||||
|
||||
If you're looking for further usage see the [examples][0] included in this repository.
|
||||
|
||||
## Run Tests
|
||||
Tests are written in [vows][1] and give complete coverage of all APIs.
|
||||
|
||||
```
|
||||
vows test/*-test.js --spec
|
||||
```
|
||||
|
||||
[0]: https://github.com/indexzero/node-pkginfo/tree/master/examples
|
||||
[1]: http://vowsjs.org
|
||||
|
||||
#### Author: [Charlie Robbins](http://nodejitsu.com)
|
||||
#### License: MIT
|
194
node_modules/pkginfo/docs/docco.css
generated
vendored
Normal file
194
node_modules/pkginfo/docs/docco.css
generated
vendored
Normal file
@ -0,0 +1,194 @@
|
||||
/*--------------------- Layout and Typography ----------------------------*/
|
||||
body {
|
||||
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
||||
font-size: 15px;
|
||||
line-height: 22px;
|
||||
color: #252519;
|
||||
margin: 0; padding: 0;
|
||||
}
|
||||
a {
|
||||
color: #261a3b;
|
||||
}
|
||||
a:visited {
|
||||
color: #261a3b;
|
||||
}
|
||||
p {
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
h4, h5, h6 {
|
||||
color: #333;
|
||||
margin: 6px 0 6px 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
h2, h3 {
|
||||
margin-bottom: 0;
|
||||
color: #000;
|
||||
}
|
||||
h1 {
|
||||
margin-top: 40px;
|
||||
margin-bottom: 15px;
|
||||
color: #000;
|
||||
}
|
||||
#container {
|
||||
position: relative;
|
||||
}
|
||||
#background {
|
||||
position: fixed;
|
||||
top: 0; left: 525px; right: 0; bottom: 0;
|
||||
background: #f5f5ff;
|
||||
border-left: 1px solid #e5e5ee;
|
||||
z-index: -1;
|
||||
}
|
||||
#jump_to, #jump_page {
|
||||
background: white;
|
||||
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
||||
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
||||
font: 10px Arial;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
text-align: right;
|
||||
}
|
||||
#jump_to, #jump_wrapper {
|
||||
position: fixed;
|
||||
right: 0; top: 0;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
#jump_wrapper {
|
||||
padding: 0;
|
||||
display: none;
|
||||
}
|
||||
#jump_to:hover #jump_wrapper {
|
||||
display: block;
|
||||
}
|
||||
#jump_page {
|
||||
padding: 5px 0 3px;
|
||||
margin: 0 0 25px 25px;
|
||||
}
|
||||
#jump_page .source {
|
||||
display: block;
|
||||
padding: 5px 10px;
|
||||
text-decoration: none;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
#jump_page .source:hover {
|
||||
background: #f5f5ff;
|
||||
}
|
||||
#jump_page .source:first-child {
|
||||
}
|
||||
table td {
|
||||
border: 0;
|
||||
outline: 0;
|
||||
}
|
||||
td.docs, th.docs {
|
||||
max-width: 450px;
|
||||
min-width: 450px;
|
||||
min-height: 5px;
|
||||
padding: 10px 25px 1px 50px;
|
||||
overflow-x: hidden;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
}
|
||||
.docs pre {
|
||||
margin: 15px 0 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
.docs p tt, .docs p code {
|
||||
background: #f8f8ff;
|
||||
border: 1px solid #dedede;
|
||||
font-size: 12px;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.pilwrap {
|
||||
position: relative;
|
||||
}
|
||||
.pilcrow {
|
||||
font: 12px Arial;
|
||||
text-decoration: none;
|
||||
color: #454545;
|
||||
position: absolute;
|
||||
top: 3px; left: -20px;
|
||||
padding: 1px 2px;
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
}
|
||||
td.docs:hover .pilcrow {
|
||||
opacity: 1;
|
||||
}
|
||||
td.code, th.code {
|
||||
padding: 14px 15px 16px 25px;
|
||||
width: 100%;
|
||||
vertical-align: top;
|
||||
background: #f5f5ff;
|
||||
border-left: 1px solid #e5e5ee;
|
||||
}
|
||||
pre, tt, code {
|
||||
font-size: 12px; line-height: 18px;
|
||||
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
|
||||
margin: 0; padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------- Syntax Highlighting -----------------------------*/
|
||||
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
||||
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
||||
body .hll { background-color: #ffffcc }
|
||||
body .c { color: #408080; font-style: italic } /* Comment */
|
||||
body .err { border: 1px solid #FF0000 } /* Error */
|
||||
body .k { color: #954121 } /* Keyword */
|
||||
body .o { color: #666666 } /* Operator */
|
||||
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
||||
body .cp { color: #BC7A00 } /* Comment.Preproc */
|
||||
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
||||
body .cs { color: #408080; font-style: italic } /* Comment.Special */
|
||||
body .gd { color: #A00000 } /* Generic.Deleted */
|
||||
body .ge { font-style: italic } /* Generic.Emph */
|
||||
body .gr { color: #FF0000 } /* Generic.Error */
|
||||
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||
body .gi { color: #00A000 } /* Generic.Inserted */
|
||||
body .go { color: #808080 } /* Generic.Output */
|
||||
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
||||
body .gs { font-weight: bold } /* Generic.Strong */
|
||||
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||||
body .gt { color: #0040D0 } /* Generic.Traceback */
|
||||
body .kc { color: #954121 } /* Keyword.Constant */
|
||||
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
|
||||
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
|
||||
body .kp { color: #954121 } /* Keyword.Pseudo */
|
||||
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
|
||||
body .kt { color: #B00040 } /* Keyword.Type */
|
||||
body .m { color: #666666 } /* Literal.Number */
|
||||
body .s { color: #219161 } /* Literal.String */
|
||||
body .na { color: #7D9029 } /* Name.Attribute */
|
||||
body .nb { color: #954121 } /* Name.Builtin */
|
||||
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
||||
body .no { color: #880000 } /* Name.Constant */
|
||||
body .nd { color: #AA22FF } /* Name.Decorator */
|
||||
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
||||
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
||||
body .nf { color: #0000FF } /* Name.Function */
|
||||
body .nl { color: #A0A000 } /* Name.Label */
|
||||
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
||||
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
|
||||
body .nv { color: #19469D } /* Name.Variable */
|
||||
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
||||
body .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
body .mf { color: #666666 } /* Literal.Number.Float */
|
||||
body .mh { color: #666666 } /* Literal.Number.Hex */
|
||||
body .mi { color: #666666 } /* Literal.Number.Integer */
|
||||
body .mo { color: #666666 } /* Literal.Number.Oct */
|
||||
body .sb { color: #219161 } /* Literal.String.Backtick */
|
||||
body .sc { color: #219161 } /* Literal.String.Char */
|
||||
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
|
||||
body .s2 { color: #219161 } /* Literal.String.Double */
|
||||
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
||||
body .sh { color: #219161 } /* Literal.String.Heredoc */
|
||||
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
||||
body .sx { color: #954121 } /* Literal.String.Other */
|
||||
body .sr { color: #BB6688 } /* Literal.String.Regex */
|
||||
body .s1 { color: #219161 } /* Literal.String.Single */
|
||||
body .ss { color: #19469D } /* Literal.String.Symbol */
|
||||
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
|
||||
body .vc { color: #19469D } /* Name.Variable.Class */
|
||||
body .vg { color: #19469D } /* Name.Variable.Global */
|
||||
body .vi { color: #19469D } /* Name.Variable.Instance */
|
||||
body .il { color: #666666 } /* Literal.Number.Integer.Long */
|
101
node_modules/pkginfo/docs/pkginfo.html
generated
vendored
Normal file
101
node_modules/pkginfo/docs/pkginfo.html
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
<!DOCTYPE html> <html> <head> <title>pkginfo.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> pkginfo.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">¶</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
|
||||
<span class="cm"> * pkginfo.js: Top-level include for the pkginfo module</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * (C) 2011, Charlie Robbins</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> */</span>
|
||||
|
||||
<span class="kd">var</span> <span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'fs'</span><span class="p">),</span>
|
||||
<span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'path'</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">¶</a> </div> <h3>function pkginfo ([options, 'property', 'property' ..])</h3>
|
||||
|
||||
<h4>@pmodule {Module} Parent module to read from.</h4>
|
||||
|
||||
<h4>@options {Object|Array|string} <strong>Optional</strong> Options used when exposing properties.</h4>
|
||||
|
||||
<h4>@arguments {string...} <strong>Optional</strong> Specified properties to expose.</h4>
|
||||
|
||||
<p>Exposes properties from the package.json file for the parent module on
|
||||
it's exports. Valid usage:</p>
|
||||
|
||||
<p><code>require('pkginfo')()</code></p>
|
||||
|
||||
<p><code>require('pkginfo')('version', 'author');</code></p>
|
||||
|
||||
<p><code>require('pkginfo')(['version', 'author']);</code></p>
|
||||
|
||||
<p><code>require('pkginfo')({ include: ['version', 'author'] });</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">pkginfo</span> <span class="o">=</span> <span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">pmodule</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="p">[].</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">,</span> <span class="mi">2</span><span class="p">).</span><span class="nx">filter</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">arg</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="k">return</span> <span class="k">typeof</span> <span class="nx">arg</span> <span class="o">===</span> <span class="s1">'string'</span><span class="p">;</span>
|
||||
<span class="p">});</span>
|
||||
</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">¶</a> </div> <p><strong>Parse variable arguments</strong></p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">options</span><span class="p">))</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">¶</a> </div> <p>If the options passed in is an Array assume that
|
||||
it is the Array of properties to expose from the
|
||||
on the package.json file on the parent module.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">options</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">include</span><span class="o">:</span> <span class="nx">options</span> <span class="p">};</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">options</span> <span class="o">===</span> <span class="s1">'string'</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">¶</a> </div> <p>Otherwise if the first argument is a string, then
|
||||
assume that it is the first property to expose from
|
||||
the package.json file on the parent module.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">options</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">include</span><span class="o">:</span> <span class="p">[</span><span class="nx">options</span><span class="p">]</span> <span class="p">};</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">¶</a> </div> <p><strong>Setup default options</strong></p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">options</span> <span class="o">=</span> <span class="nx">options</span> <span class="o">||</span> <span class="p">{</span> <span class="nx">include</span><span class="o">:</span> <span class="p">[]</span> <span class="p">};</span>
|
||||
|
||||
<span class="k">if</span> <span class="p">(</span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">¶</a> </div> <p>If additional string arguments have been passed in
|
||||
then add them to the properties to expose on the
|
||||
parent module. </p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">options</span><span class="p">.</span><span class="nx">include</span> <span class="o">=</span> <span class="nx">options</span><span class="p">.</span><span class="nx">include</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">args</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="kd">var</span> <span class="nx">pkg</span> <span class="o">=</span> <span class="nx">pkginfo</span><span class="p">.</span><span class="nx">read</span><span class="p">(</span><span class="nx">pmodule</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">dir</span><span class="p">).</span><span class="kr">package</span><span class="p">;</span>
|
||||
<span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">pkg</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">include</span><span class="p">.</span><span class="nx">length</span> <span class="o">></span> <span class="mi">0</span> <span class="o">&&</span> <span class="o">!~</span><span class="nx">options</span><span class="p">.</span><span class="nx">include</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">key</span><span class="p">))</span> <span class="p">{</span>
|
||||
<span class="k">return</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">pmodule</span><span class="p">.</span><span class="nx">exports</span><span class="p">[</span><span class="nx">key</span><span class="p">])</span> <span class="p">{</span>
|
||||
<span class="nx">pmodule</span><span class="p">.</span><span class="nx">exports</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">pkg</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">});</span>
|
||||
|
||||
<span class="k">return</span> <span class="nx">pkginfo</span><span class="p">;</span>
|
||||
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">¶</a> </div> <h3>function find (dir)</h3>
|
||||
|
||||
<h4>@pmodule {Module} Parent module to read from.</h4>
|
||||
|
||||
<h4>@dir {string} <strong>Optional</strong> Directory to start search from.</h4>
|
||||
|
||||
<p>Searches up the directory tree from <code>dir</code> until it finds a directory
|
||||
which contains a <code>package.json</code> file. </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">pkginfo</span><span class="p">.</span><span class="nx">find</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">pmodule</span><span class="p">,</span> <span class="nx">dir</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="nx">dir</span> <span class="o">=</span> <span class="nx">dir</span> <span class="o">||</span> <span class="nx">pmodule</span><span class="p">.</span><span class="nx">filename</span><span class="p">;</span>
|
||||
<span class="nx">dir</span> <span class="o">=</span> <span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">dir</span><span class="p">);</span>
|
||||
|
||||
<span class="kd">var</span> <span class="nx">files</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">readdirSync</span><span class="p">(</span><span class="nx">dir</span><span class="p">);</span>
|
||||
|
||||
<span class="k">if</span> <span class="p">(</span><span class="o">~</span><span class="nx">files</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">'package.json'</span><span class="p">))</span> <span class="p">{</span>
|
||||
<span class="k">return</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">dir</span><span class="p">,</span> <span class="s1">'package.json'</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">if</span> <span class="p">(</span><span class="nx">dir</span> <span class="o">===</span> <span class="s1">'/'</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">'Could not find package.json up from: '</span> <span class="o">+</span> <span class="nx">dir</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">return</span> <span class="nx">pkginfo</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="nx">dir</span><span class="p">);</span>
|
||||
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">¶</a> </div> <h3>function read (pmodule, dir)</h3>
|
||||
|
||||
<h4>@pmodule {Module} Parent module to read from.</h4>
|
||||
|
||||
<h4>@dir {string} <strong>Optional</strong> Directory to start search from.</h4>
|
||||
|
||||
<p>Searches up the directory tree from <code>dir</code> until it finds a directory
|
||||
which contains a <code>package.json</code> file and returns the package information.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">pkginfo</span><span class="p">.</span><span class="nx">read</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">pmodule</span><span class="p">,</span> <span class="nx">dir</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="nx">dir</span> <span class="o">=</span> <span class="nx">pkginfo</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="nx">pmodule</span><span class="p">,</span> <span class="nx">dir</span><span class="p">);</span>
|
||||
|
||||
<span class="kd">var</span> <span class="nx">data</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">dir</span><span class="p">).</span><span class="nx">toString</span><span class="p">();</span>
|
||||
|
||||
<span class="k">return</span> <span class="p">{</span>
|
||||
<span class="nx">dir</span><span class="o">:</span> <span class="nx">dir</span><span class="p">,</span>
|
||||
<span class="kr">package</span><span class="o">:</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span>
|
||||
<span class="p">};</span>
|
||||
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">¶</a> </div> <p>Call <code>pkginfo</code> on this module and expose version.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">pkginfo</span><span class="p">(</span><span class="nx">module</span><span class="p">,</span> <span class="p">{</span>
|
||||
<span class="nx">dir</span><span class="o">:</span> <span class="nx">__dirname</span><span class="p">,</span>
|
||||
<span class="nx">include</span><span class="o">:</span> <span class="p">[</span><span class="s1">'version'</span><span class="p">],</span>
|
||||
<span class="nx">target</span><span class="o">:</span> <span class="nx">pkginfo</span>
|
||||
<span class="p">});</span>
|
||||
|
||||
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
|
19
node_modules/pkginfo/examples/all-properties.js
generated
vendored
Normal file
19
node_modules/pkginfo/examples/all-properties.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* all-properties.js: Sample of including all properties from a package.json file
|
||||
*
|
||||
* (C) 2011, Charlie Robbins
|
||||
*
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
pkginfo = require('../lib/pkginfo')(module);
|
||||
|
||||
exports.someFunction = function () {
|
||||
console.log('some of your custom logic here');
|
||||
};
|
||||
|
||||
console.log('Inspecting module:');
|
||||
console.dir(module.exports);
|
||||
|
||||
console.log('\nAll exports exposed:');
|
||||
console.error(Object.keys(module.exports));
|
20
node_modules/pkginfo/examples/array-argument.js
generated
vendored
Normal file
20
node_modules/pkginfo/examples/array-argument.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* array-argument.js: Sample of including specific properties from a package.json file
|
||||
* using Array argument syntax.
|
||||
*
|
||||
* (C) 2011, Charlie Robbins
|
||||
*
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
pkginfo = require('../lib/pkginfo')(module, ['version', 'author']);
|
||||
|
||||
exports.someFunction = function () {
|
||||
console.log('some of your custom logic here');
|
||||
};
|
||||
|
||||
console.log('Inspecting module:');
|
||||
console.dir(module.exports);
|
||||
|
||||
console.log('\nAll exports exposed:');
|
||||
console.error(Object.keys(module.exports));
|
19
node_modules/pkginfo/examples/multiple-properties.js
generated
vendored
Normal file
19
node_modules/pkginfo/examples/multiple-properties.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* multiple-properties.js: Sample of including multiple properties from a package.json file
|
||||
*
|
||||
* (C) 2011, Charlie Robbins
|
||||
*
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
pkginfo = require('../lib/pkginfo')(module, 'version', 'author');
|
||||
|
||||
exports.someFunction = function () {
|
||||
console.log('some of your custom logic here');
|
||||
};
|
||||
|
||||
console.log('Inspecting module:');
|
||||
console.dir(module.exports);
|
||||
|
||||
console.log('\nAll exports exposed:');
|
||||
console.error(Object.keys(module.exports));
|
22
node_modules/pkginfo/examples/object-argument.js
generated
vendored
Normal file
22
node_modules/pkginfo/examples/object-argument.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* object-argument.js: Sample of including specific properties from a package.json file
|
||||
* using Object argument syntax.
|
||||
*
|
||||
* (C) 2011, Charlie Robbins
|
||||
*
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
pkginfo = require('../lib/pkginfo')(module, {
|
||||
include: ['version', 'author']
|
||||
});
|
||||
|
||||
exports.someFunction = function () {
|
||||
console.log('some of your custom logic here');
|
||||
};
|
||||
|
||||
console.log('Inspecting module:');
|
||||
console.dir(module.exports);
|
||||
|
||||
console.log('\nAll exports exposed:');
|
||||
console.error(Object.keys(module.exports));
|
10
node_modules/pkginfo/examples/package.json
generated
vendored
Normal file
10
node_modules/pkginfo/examples/package.json
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "simple-app",
|
||||
"description": "A test fixture for pkginfo",
|
||||
"version": "0.1.0",
|
||||
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
|
||||
"keywords": ["test", "fixture"],
|
||||
"main": "./index.js",
|
||||
"scripts": { "test": "vows test/*-test.js --spec" },
|
||||
"engines": { "node": ">= 0.4.0" }
|
||||
}
|
19
node_modules/pkginfo/examples/single-property.js
generated
vendored
Normal file
19
node_modules/pkginfo/examples/single-property.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* single-property.js: Sample of including a single specific properties from a package.json file
|
||||
*
|
||||
* (C) 2011, Charlie Robbins
|
||||
*
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
pkginfo = require('../lib/pkginfo')(module, 'version');
|
||||
|
||||
exports.someFunction = function () {
|
||||
console.log('some of your custom logic here');
|
||||
};
|
||||
|
||||
console.log('Inspecting module:');
|
||||
console.dir(module.exports);
|
||||
|
||||
console.log('\nAll exports exposed:');
|
||||
console.error(Object.keys(module.exports));
|
11
node_modules/pkginfo/examples/subdir/package.json
generated
vendored
Normal file
11
node_modules/pkginfo/examples/subdir/package.json
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "simple-app-subdir",
|
||||
"description": "A test fixture for pkginfo",
|
||||
"version": "0.1.0",
|
||||
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
|
||||
"keywords": ["test", "fixture"],
|
||||
"main": "./index.js",
|
||||
"scripts": { "test": "vows test/*-test.js --spec" },
|
||||
"engines": { "node": ">= 0.4.0" },
|
||||
"subdironly": "true"
|
||||
}
|
20
node_modules/pkginfo/examples/target-dir.js
generated
vendored
Normal file
20
node_modules/pkginfo/examples/target-dir.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* multiple-properties.js: Sample of including multiple properties from a package.json file
|
||||
*
|
||||
* (C) 2011, Charlie Robbins
|
||||
*
|
||||
*/
|
||||
|
||||
var util = require('util'),
|
||||
path = require('path'),
|
||||
pkginfo = require('../lib/pkginfo')(module, { dir: path.resolve(__dirname, 'subdir' )});
|
||||
|
||||
exports.someFunction = function () {
|
||||
console.log('some of your custom logic here');
|
||||
};
|
||||
|
||||
console.log('Inspecting module:');
|
||||
console.dir(module.exports);
|
||||
|
||||
console.log('\nAll exports exposed:');
|
||||
console.error(Object.keys(module.exports));
|
136
node_modules/pkginfo/lib/pkginfo.js
generated
vendored
Normal file
136
node_modules/pkginfo/lib/pkginfo.js
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* pkginfo.js: Top-level include for the pkginfo module
|
||||
*
|
||||
* (C) 2011, Charlie Robbins
|
||||
*
|
||||
*/
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path');
|
||||
|
||||
//
|
||||
// ### function pkginfo ([options, 'property', 'property' ..])
|
||||
// #### @pmodule {Module} Parent module to read from.
|
||||
// #### @options {Object|Array|string} **Optional** Options used when exposing properties.
|
||||
// #### @arguments {string...} **Optional** Specified properties to expose.
|
||||
// Exposes properties from the package.json file for the parent module on
|
||||
// it's exports. Valid usage:
|
||||
//
|
||||
// `require('pkginfo')()`
|
||||
//
|
||||
// `require('pkginfo')('version', 'author');`
|
||||
//
|
||||
// `require('pkginfo')(['version', 'author']);`
|
||||
//
|
||||
// `require('pkginfo')({ include: ['version', 'author'] });`
|
||||
//
|
||||
var pkginfo = module.exports = function (pmodule, options) {
|
||||
var args = [].slice.call(arguments, 2).filter(function (arg) {
|
||||
return typeof arg === 'string';
|
||||
});
|
||||
|
||||
//
|
||||
// **Parse variable arguments**
|
||||
//
|
||||
if (Array.isArray(options)) {
|
||||
//
|
||||
// If the options passed in is an Array assume that
|
||||
// it is the Array of properties to expose from the
|
||||
// on the package.json file on the parent module.
|
||||
//
|
||||
options = { include: options };
|
||||
}
|
||||
else if (typeof options === 'string') {
|
||||
//
|
||||
// Otherwise if the first argument is a string, then
|
||||
// assume that it is the first property to expose from
|
||||
// the package.json file on the parent module.
|
||||
//
|
||||
options = { include: [options] };
|
||||
}
|
||||
|
||||
//
|
||||
// **Setup default options**
|
||||
//
|
||||
options = options || {};
|
||||
|
||||
// ensure that includes have been defined
|
||||
options.include = options.include || [];
|
||||
|
||||
if (args.length > 0) {
|
||||
//
|
||||
// If additional string arguments have been passed in
|
||||
// then add them to the properties to expose on the
|
||||
// parent module.
|
||||
//
|
||||
options.include = options.include.concat(args);
|
||||
}
|
||||
|
||||
var pkg = pkginfo.read(pmodule, options.dir).package;
|
||||
Object.keys(pkg).forEach(function (key) {
|
||||
if (options.include.length > 0 && !~options.include.indexOf(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pmodule.exports[key]) {
|
||||
pmodule.exports[key] = pkg[key];
|
||||
}
|
||||
});
|
||||
|
||||
return pkginfo;
|
||||
};
|
||||
|
||||
//
|
||||
// ### function find (dir)
|
||||
// #### @pmodule {Module} Parent module to read from.
|
||||
// #### @dir {string} **Optional** Directory to start search from.
|
||||
// Searches up the directory tree from `dir` until it finds a directory
|
||||
// which contains a `package.json` file.
|
||||
//
|
||||
pkginfo.find = function (pmodule, dir) {
|
||||
if (! dir) {
|
||||
dir = path.dirname(pmodule.filename);
|
||||
}
|
||||
|
||||
var files = fs.readdirSync(dir);
|
||||
|
||||
if (~files.indexOf('package.json')) {
|
||||
return path.join(dir, 'package.json');
|
||||
}
|
||||
|
||||
if (dir === '/') {
|
||||
throw new Error('Could not find package.json up from: ' + dir);
|
||||
}
|
||||
else if (!dir || dir === '.') {
|
||||
throw new Error('Cannot find package.json from unspecified directory');
|
||||
}
|
||||
|
||||
return pkginfo.find(pmodule, path.dirname(dir));
|
||||
};
|
||||
|
||||
//
|
||||
// ### function read (pmodule, dir)
|
||||
// #### @pmodule {Module} Parent module to read from.
|
||||
// #### @dir {string} **Optional** Directory to start search from.
|
||||
// Searches up the directory tree from `dir` until it finds a directory
|
||||
// which contains a `package.json` file and returns the package information.
|
||||
//
|
||||
pkginfo.read = function (pmodule, dir) {
|
||||
dir = pkginfo.find(pmodule, dir);
|
||||
|
||||
var data = fs.readFileSync(dir).toString();
|
||||
|
||||
return {
|
||||
dir: dir,
|
||||
package: JSON.parse(data)
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// Call `pkginfo` on this module and expose version.
|
||||
//
|
||||
pkginfo(module, {
|
||||
dir: __dirname,
|
||||
include: ['version'],
|
||||
target: pkginfo
|
||||
});
|
82
node_modules/pkginfo/package.json
generated
vendored
Normal file
82
node_modules/pkginfo/package.json
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"pkginfo@0.3.x",
|
||||
"/Users/akira/src/biomedjs/node_modules/winston"
|
||||
]
|
||||
],
|
||||
"_from": "pkginfo@>=0.3.0 <0.4.0",
|
||||
"_id": "pkginfo@0.3.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/pkginfo",
|
||||
"_nodeVersion": "0.10.38",
|
||||
"_npmUser": {
|
||||
"email": "charlie.robbins@gmail.com",
|
||||
"name": "indexzero"
|
||||
},
|
||||
"_npmVersion": "2.14.1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "pkginfo",
|
||||
"raw": "pkginfo@0.3.x",
|
||||
"rawSpec": "0.3.x",
|
||||
"scope": null,
|
||||
"spec": ">=0.3.0 <0.4.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/winston"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz",
|
||||
"_shasum": "5b29f6a81f70717142e09e765bbeab97b4f81e21",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "pkginfo@0.3.x",
|
||||
"_where": "/Users/akira/src/biomedjs/node_modules/winston",
|
||||
"author": {
|
||||
"email": "charlie.robbins@gmail.com",
|
||||
"name": "Charlie Robbins"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/indexzero/node-pkginfo/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "An easy way to expose properties on a module from a package.json",
|
||||
"devDependencies": {
|
||||
"vows": "0.7.x"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "5b29f6a81f70717142e09e765bbeab97b4f81e21",
|
||||
"tarball": "http://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"gitHead": "630fcf486543ee48b4c16afc575c0421fe039f26",
|
||||
"homepage": "https://github.com/indexzero/node-pkginfo#readme",
|
||||
"keywords": [
|
||||
"info",
|
||||
"package.json",
|
||||
"tools"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./lib/pkginfo.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "indexzero",
|
||||
"email": "charlie.robbins@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "pkginfo",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/indexzero/node-pkginfo.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vows test/*-test.js --spec"
|
||||
},
|
||||
"version": "0.3.1"
|
||||
}
|
83
node_modules/pkginfo/test/pkginfo-test.js
generated
vendored
Normal file
83
node_modules/pkginfo/test/pkginfo-test.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* pkginfo-test.js: Tests for the pkginfo module.
|
||||
*
|
||||
* (C) 2011, Charlie Robbins
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
exec = require('child_process').exec,
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
vows = require('vows'),
|
||||
pkginfo = require('../lib/pkginfo');
|
||||
|
||||
function assertProperties (source, target) {
|
||||
assert.lengthOf(source, target.length + 1);
|
||||
target.forEach(function (prop) {
|
||||
assert.isTrue(!!~source.indexOf(prop));
|
||||
});
|
||||
}
|
||||
|
||||
function compareWithExample(targetPath) {
|
||||
var examplePaths = ['package.json'];
|
||||
|
||||
if (targetPath) {
|
||||
examplePaths.unshift(targetPath);
|
||||
}
|
||||
|
||||
return function(exposed) {
|
||||
var pkg = fs.readFileSync(path.join.apply(null, [__dirname, '..', 'examples'].concat(examplePaths))).toString(),
|
||||
keys = Object.keys(JSON.parse(pkg));
|
||||
|
||||
assertProperties(exposed, keys);
|
||||
};
|
||||
}
|
||||
|
||||
function testExposes (options) {
|
||||
return {
|
||||
topic: function () {
|
||||
exec('node ' + path.join(__dirname, '..', 'examples', options.script), this.callback);
|
||||
},
|
||||
"should expose that property correctly": function (err, stdout, stderr) {
|
||||
assert.isNull(err);
|
||||
|
||||
var exposed = stderr.match(/'(\w+)'/ig).map(function (p) {
|
||||
return p.substring(1, p.length - 1);
|
||||
});
|
||||
|
||||
return !options.assert
|
||||
? assertProperties(exposed, options.properties)
|
||||
: options.assert(exposed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vows.describe('pkginfo').addBatch({
|
||||
"When using the pkginfo module": {
|
||||
"and passed a single `string` argument": testExposes({
|
||||
script: 'single-property.js',
|
||||
properties: ['version']
|
||||
}),
|
||||
"and passed multiple `string` arguments": testExposes({
|
||||
script: 'multiple-properties.js',
|
||||
properties: ['version', 'author']
|
||||
}),
|
||||
"and passed an `object` argument": testExposes({
|
||||
script: 'object-argument.js',
|
||||
properties: ['version', 'author']
|
||||
}),
|
||||
"and passed an `array` argument": testExposes({
|
||||
script: 'array-argument.js',
|
||||
properties: ['version', 'author']
|
||||
}),
|
||||
"and read from a specified directory": testExposes({
|
||||
script: 'target-dir.js',
|
||||
assert: compareWithExample('subdir')
|
||||
}),
|
||||
"and passed no arguments": testExposes({
|
||||
script: 'all-properties.js',
|
||||
assert: compareWithExample()
|
||||
})
|
||||
}
|
||||
}).export(module);
|
Reference in New Issue
Block a user