Noisy Pneumatic Mnemonic

    requirement

    0.0.8 • Public • Published

    Requirement

    Install

    npm install requirement --save

    Why index

    Generating index files allows you to do a require on any directory and get back an object representing the directory structure.

    For big projects, this allows you to require dependencies in a more concise way.

    Example

    cms/index.coffee:

    # Generated by `gulp index`. 
    # 
    module.exports =
      Editor:
        Article: require "./editor/cms.editor.article"
        Header: require "./editor/cms.editor.header"
      Header: require "./header/cms.header"
      Modals:
        Cropper: require "./modals/cms.modals.cropper"
        Embed: require "./modals/cms.modals.embed"
        Media: require "./modals/cms.modals.media"
        Headers:
          Publish: require "./modals/headers/cms.modals.headers.publish"
          Strip: require "./modals/headers/cms.modals.headers.strip"

    Now requiring becomes easy:

    { EditorHeader } = require "./cms"

    Indexing with explicit requires also keeps your project compliant with Browserify compilation.

    Build indices

    This gulp task generates an index.coffee file in a directory and its subdirectories.

    gulp = require "gulp"
    Task = require("requirement").Task
     
    gulp.task "index"->
      paths = [
        "#{__dirname}/../../app/scripts"
        "#{__dirname}/../../app2/components"
      ]
      new Task { paths }

    Keywords

    none

    Install

    npm i requirement

    DownloadsWeekly Downloads

    10

    Version

    0.0.8

    License

    MIT

    Last publish

    Collaborators

    • winton