A Node.JS module, provides an object oriented wrapper for the NPM API. It allow to automatically install modules for Node.js projects.
JavaScript
Switch branches/tags
Nothing to show
Latest commit 6674406 Jun 15, 2013 @eladelrom init commit
Permalink
Failed to load latest commit information.
lib
LICENSE
README.md
package.json

README.md

JavaScript NPM Wrapper Utility for Node.JS

A Node.JS module, provides an object oriented wrapper for the NPM API. It allow to automatically install modules for Node.js projects.

It has features to look through the node_module files, see the "require" statements, and then list these for your package.json file or other usages.

Installation

Install with the Node.JS package manager npm:

  $ npm install npm-util

or

Install via git clone:

  $ git clone git://github.com/EladElrom/npm-util.git

Wrapper utility to handle NPM packager

Example

See list of installed modules:

npm = require('npm-util');

npm.getInstalledModules(function (msg) {
    console.log(msg);
});

You could install all modules in package.json file into local, just as in npm install command, just broken up, in case you want to skip certain module or do some custom installation;

Impl.prototype.installAll = function() {
    var npm = require('npm-util'),
        i;

    npm.createNodeModulesDirectory();
    var data = npm.getPackageContent('dependencies');
    for (i = 0; i > data.length; i++) {
        Impl.prototype.installNpm(data[i]);
    }
};

Impl.prototype.installNpm = function (pkg) {
    npm = require('npm-util');
    npm = new npm();

    npm.exec('install', [pkg], function (err, data) {
        if (err) {
            throw err;
        }
        logger.log('Installing: ' + pkg);
    });
};

Or you can just use the NPM auto installer method;

npm = require('npm-util');
npm = new npm();

npm.exec('install', function (err, data) {
    if (err) {
        throw err;
    }
});

LICENSE

MIT license. See the LICENSE file for details.