1. mothership
Helps a module find its package.json mothership.
mothership
Package: mothership
Created by: thlorenz
Last modified: Mon, 20 Jun 2022 10:06:13 GMT
Version: 0.3.0
License: MIT
Downloads: 110,221
Repository: https://github.com/thlorenz/mothership

Install

npm install mothership
yarn add mothership

mothership build status

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.json

Installation

npm install mothership

API

mothership(start, ismothership, cb)

Searches 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.

mothership result
  • path: full path to the package.json that is the mother ship
  • pack: the package.json object, same that was passed to ismothership
Parameters:
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

Source:

mothership::sync(start, ismothership) → {string}

Synchronous version of mothership.

Parameters:
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

Source:
Returns:

full path to package.json that is the mothership or null if it wasn't found

Type
string

generated with docme

License

MIT

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code