1 | # mothership [![build status](https://secure.travis-ci.org/thlorenz/mothership.png)](http://travis-ci.org/thlorenz/mothership)
|
2 |
|
3 | Helps a module find its `package.json` mothership.
|
4 |
|
5 | ```js
|
6 | var findShip = require('mothership')
|
7 | , path = require('path');
|
8 |
|
9 | findShip(
|
10 | path.join(__dirname, 'uno', 'dos', 'tres')
|
11 | , function ismothership (pack) {
|
12 | return !!(pack.dependencies && pack.dependencies.unodep);
|
13 | }
|
14 | , function (err, res) {
|
15 | if (err) return console.error(err);
|
16 | console.log('first mothership', res.path); // => [..]/example/uno/package.json
|
17 | }
|
18 | )
|
19 | ```
|
20 |
|
21 | ## Installation
|
22 |
|
23 | npm install mothership
|
24 |
|
25 | ## API
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | <div>
|
31 | <div class="jsdoc-githubify">
|
32 | <section>
|
33 | <article>
|
34 | <div class="container-overview">
|
35 | <dl class="details">
|
36 | </dl>
|
37 | </div>
|
38 | <dl>
|
39 | <dt>
|
40 | <h4 class="name" id="mothership"><span class="type-signature"></span>mothership<span class="signature">(start, ismothership, cb)</span><span class="type-signature"></span></h4>
|
41 | </dt>
|
42 | <dd>
|
43 | <div class="description">
|
44 | <p>Searches upwards from start for package.json files, asking for each if it is the mothership.
|
45 | If a mothership is found it calls back with that.
|
46 | If it reaches the top of the univers it calls back with nothing.</p>
|
47 | <h5>mothership result</h5>
|
48 | <ul>
|
49 | <li><code>path</code>: full path to the <code>package.json</code> that is the mother ship</li>
|
50 | <li><code>pack</code>: the <code>package.json</code> object, same that was passed to ismothership</li>
|
51 | </ul>
|
52 | </div>
|
53 | <h5>Parameters:</h5>
|
54 | <table class="params">
|
55 | <thead>
|
56 | <tr>
|
57 | <th>Name</th>
|
58 | <th>Type</th>
|
59 | <th class="last">Description</th>
|
60 | </tr>
|
61 | </thead>
|
62 | <tbody>
|
63 | <tr>
|
64 | <td class="name"><code>start</code></td>
|
65 | <td class="type">
|
66 | <span class="param-type">string</span>
|
67 | </td>
|
68 | <td class="description last"><p>full path at which to start looking for the mothership</p></td>
|
69 | </tr>
|
70 | <tr>
|
71 | <td class="name"><code>ismothership</code></td>
|
72 | <td class="type">
|
73 | <span class="param-type">function</span>
|
74 | </td>
|
75 | <td class="description last"><p>invoked with the package object, needs to return true if it is the mothership</p></td>
|
76 | </tr>
|
77 | <tr>
|
78 | <td class="name"><code>cb</code></td>
|
79 | <td class="type">
|
80 | <span class="param-type">function</span>
|
81 | </td>
|
82 | <td class="description last"><p>called back with either an error or full path to package.json that is the mothership</p></td>
|
83 | </tr>
|
84 | </tbody>
|
85 | </table>
|
86 | <dl class="details">
|
87 | <dt class="tag-source">Source:</dt>
|
88 | <dd class="tag-source"><ul class="dummy">
|
89 | <li>
|
90 | <a href="https://github.com/thlorenz/mothership/blob/master/index.js">index.js</a>
|
91 | <span>, </span>
|
92 | <a href="https://github.com/thlorenz/mothership/blob/master/index.js#L8">lineno 8</a>
|
93 | </li>
|
94 | </ul></dd>
|
95 | </dl>
|
96 | </dd>
|
97 | </dl>
|
98 | </article>
|
99 | </section>
|
100 | </div>
|
101 |
|
102 | *generated with [docme](https://github.com/thlorenz/docme)*
|
103 | </div>
|
104 |
|
105 |
|
106 | ## License
|
107 |
|
108 | MIT
|