package
Helps a module find its package.json mothership.
npm install mothershipGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
5.0 kB
Includes dependencies.

Helps a module find its package.json mothership.
var mothership = require('mothership')
, path = require('path');
mothership(
path.join(__dirname, 'uno', 'dos', 'tres')
, function ismothership (pack) {
return !!(pack.dependencies && pack.dependencies.unodep);
}
, function (err, res) {
if (err) return console.error(err);
console.log('first mothership', res.path); // => [..]/example/uno/package.json
}
)
// Synchronous
var res = mothership.sync(
path.join(__dirname, 'uno', 'dos', 'tres')
, function ismothership (pack) {
return !!(pack.dependencies && pack.dependencies.unodep);
}
)
console.log('found mothership', res.path); // => [..]/example/uno/package.jsonnpm install mothershipSearches upwards from start for package.json files, asking for each if it is the mothership. If a mothership is found it calls back with that. If it reaches the top of the univers it calls back with nothing.
path: full path to the package.json that is the mother shippack: the package.json object, same that was passed to ismothership| Name | Type | Description |
|---|---|---|
start | string | full path at which to start looking for the mothership |
ismothership | function | invoked with the package object, needs to return true if it is the mothership |
cb | function | called back with either an error or full path to package.json that is the mothership |
MIT
Synchronous version of mothership.
| Name | Type | Description |
|---|---|---|
start | string | full path at which to start looking for the mothership |
ismothership | function | invoked with the package object, needs to return true if it is the mothership |
full path to package.json that is the mothership or null if it wasn't found
generated with docme