node-cjs-autoloader

0.1.3 • Public • Published

node-cjs-autoloader v0.1.3

Build Status

Search the path of a required script in a CommonJS project.

Getting Started

Install this plugin with this command:

npm install node-cjs-autoloader

Description

This Autoloader basicly search for requested files in a certain pattern. When the Autoloader finds something it'll return the absolute path to the file.

Basic example usage:

var autoloader = new Autoloader();

autoloader.get(__filename,'grunt',function(path){
    console.log('grunt is here: ',path); //will print the full path to grunt
});

Advanced example usage:

var autoloader = new Autoloader({
    debugging: true,
    dothrow: false,
    lookupDirectories: [
        'home',
        'usr',
        'somewhere'
    ],
    onNewPackage: function(autoloader,pkg,nodeModule,json,moduleName,currDirectory){
        console.log('Successful reading package: ' + pkg);
    },
    onNewDirectory: function(autoloader,directory,sourceModule,targetModule,directories){
        console.log('Lookup directory: ' + directory);
    }
});

autoloader.get(__filename,'grunt',function(path){
    console.log('grunt is here: ',path); //will print the full path to grunt
});

/node-cjs-autoloader/

    Package Sidebar

    Install

    npm i node-cjs-autoloader

    Weekly Downloads

    4

    Version

    0.1.3

    License

    none

    Last publish

    Collaborators

    • ayecue