Noncollinear Perpendicular Microcrystalline

    require-extensions

    0.0.4 • Public • Published

    require-extensions Travis Coverage Status Downloads

    Get the extensions of executable file names as glob pattern or regular expression

    Install with npm

    $ npm i require-extensions --save

    Usage

    require.extensions.glob             // -> {.js,.coffee}
    require.extensions.regexp           // -> /(?:\.js|\.coffee)/
    require.extensions.regexp.string    // -> '(?:\.js|\.coffee)'
    require('require-extensions');
     
    var glob = require('glob');
    var files = glob.sync("plugins/*." + require.extensions.glob);
    // -> ['plugins/thisfile.js', 'plugins/thatfile.coffee', 'plugins/thisfile.litcoffee']
     
    files[0].match(require.extensions.regexp);
    // -> != null

    Functions

    glob

    return a glob pattern for require.extensions

    regexp

    return a new RegExp object that matches require.extensions

    regexp_string

    return a new String regular expression that matches require.extensions

    Motivation

    Many libraries use a hardcoded .js string to discover executable file names, unfortunately leaving out other extensions that contain executable code such as .coffee, .litcoffee, and potentially others that are accessible through Node’s require.extensions property. By making this property accessible as a glob pattern and regular expression, it will become easier to use it as a search pattern and load code that was written in other languages or dialects.

    Author

    Andreas Pizsa

    License

    Copyright © 2016 Andreas Pizsa Released under the MIT license.


    This file was generated by verb-cli on January 21, 2016.

    Install

    npm i require-extensions

    DownloadsWeekly Downloads

    10

    Version

    0.0.4

    License

    MIT

    Last publish

    Collaborators

    • andreaspizsa