lib/node-kit.js
function Kit(str, variables, forbiddenPaths) {
    this._variables = variables || {};
    this._forbiddenPaths = forbiddenPaths || [];

    // Import file
    if (fs.existsSync(str)) {
        this.fileContents = fs.readFileSync(str).toString();
        this.filename = path.basename(str);
        this._fileDir = path.dirname(str);

        if (this._forbiddenPaths.indexOf(str) !== -1) {
            throw new Error('Error: infinite import loop detected. (e.g. File A imports File B, which imports File A.) You must fix this before the file can be compiled.');
        }
        this._forbiddenPaths.push(str);
    }

    // Anonymous string
    else {
        this.fileContents = str.toString();
        this.filename = '<anonymous>';
        this._fileDir = '';
    }
}
function Kit(str, variables, forbiddenPaths) {
    this._variables = variables || {};
    this._forbiddenPaths = forbiddenPaths || [];

    // Import file
    if (fs.existsSync(str)) {
        this.fileContents = fs.readFileSync(str).toString();
        this.filename = path.basename(str);
        this._fileDir = path.dirname(str);

        if (this._forbiddenPaths.indexOf(str) !== -1) {
            throw new Error('Error: infinite import loop detected. (e.g. File A imports File B, which imports File A.) You must fix this before the file can be compiled.');
        }
        this._forbiddenPaths.push(str);
    }

    // Anonymous string
    else {
        this.fileContents = str.toString();
        this.filename = '<anonymous>';
        this._fileDir = '';
    }
}
function Kit ( str , variables , forbiddenPaths ) { this . _variables = variables || { } ; this . _forbiddenPaths = forbiddenPaths || [ ] ; // Import file if ( fs . existsSync ( str ) ) { this . fileContents = fs . readFileSync ( str ) . toString ( ) ; this . filename = path . basename ( str ) ; this . _fileDir = path . dirname ( str ) ; if ( this . _forbiddenPaths . indexOf ( str ) !== - 1 ) { throw new Error ( 'Error: infinite import loop detected. (e.g. File A imports File B, which imports File A.) You must fix this before the file can be compiled.' ) ; } this . _forbiddenPaths . push ( str ) ; } // Anonymous string else { this . fileContents = str . toString ( ) ; this . filename = '<anonymous>' ; this . _fileDir = '' ; } }
Create a new Kit object
@param {string}        str
@param {Object}        variables
@param {Array<string>} forbiddenPaths
Create a new Kit object