Neurotoxin Powered Marketing
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    ngn-utilpublic

    ngn-util

    NGN System Utilities

    Installation: npm install ngn-util.

    Auto-install missing module.

    The following code will automatically and synchronously install a module if it is not already installed. Supports global installs, which automatically links the global module to the current working directory. Supports alternative npm registry.

    var util = require('ngn-util');
    var uuid = util.require('node-uuid');

    Options

    util.require('module'[,<boolean:global>,<string:private_registry_url>]);

    npm

    The system utilites also provide some wrappers around npm. This includes:

    • npm.install()
    • npm.installSync()
    • npm.installed()
    • npm.globalDirectory
    • npm.globalLink()
    var util = require('ngn-util');
     
    var config = {
      package: 'myModule',
      name: 'My Awesome Module', // <-- Descriptive name for module (used in CLI status)
      global: false,
      registry: 'http://private.com/registry'
    };
     
    // Install a module asynchronously
    util.npm.install(config,function(){
      console.log('Installed!');
    });
     
    // Install a module synchronously
    util.npm.installSync(config);
     
    console.log(util.npm.globalDirectory); // Show the path to npm global
     
    util.npm.globalLink('to','from',function(){
      console.log('Linked!');
    });

    To check if a module is already installed:

    var util = require('ngn-util');
     
    console.log(util.npm.installed('myModule'));

    Returns an object like:

    {
      global: false,
      local: true
    }

    The method can be passed an optional second argument of which directory should contain the module if installed locally.

    Example: util.npm.installed('myModule','/path/to/my/project');

    Wrapped Modules

    tl;dr:This module auto-installs what NGN needs.

    The NGN Utility library will manage certain module dependencies dynamically. For example, if var util = require('ngn-util'); util.execSync(...); is called, the utility will attempt to install the exec-sync module. If it is not found, it will be installed globally and a link will be created. This allows reuse of common modules throughout the NGN platform without adding redundant installations of the same modules (as is common many node modules). Of course, individual modules can be overridden as necessary.

    The following modules are wrapped into the NGN utilities:

    • exec-sync (Execute commands synchronously... CLI-ONLY!)
    • bcrypt (strong encryption)
    • seq (flow control)
    • read (CLI prompt)
    • colors (colorized console output)
    • optimist (CLI argument utility)

    Keywords

    none

    install

    npm i ngn-util

    Downloadsweekly downloads

    3

    version

    0.0.1

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar