Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

export-dirs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

export-dirs

Export directories and their files as node.js modules.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-5.82%
Maintainers
1
Weekly downloads
 
Created
Source

export-dirs NPM version Build Status

Export directories and their files as node.js modules.

Install with npm

npm i export-dirs --save

Usage

Pass the directory as the only argument:

module.exports = require('export-dirs')(__dirname);

Example:

Given the following directory structure:

fixtures/
  one/
    a.js
    b.js
    c.js
    // use `export-files` in this index.js
    index.js
  two/
    d.js
    e.js
    f.js
    // use `export-files` in this index.js
    index.js
  three/
    g.js
    h.js
    i.js
    // use `export-files` in this index.js
    index.js
  x.js
  y.js
  z.js
  // use `export-dirs` in this index.js
  index.js

The result would be:

// all modules are flattened onto the `_` object
{ _:
   { z: [Function],
     y: [Function],
     x: [Function],
     f: [Function],
     e: [Function],
     d: [Function],
     i: [Function],
     h: [Function],
     g: [Function],
     c: [Function],
     b: [Function],
     a: [Function] },
  // files from the same directory as export-dirs
  z: [Function],
  y: [Function],
  x: [Function],
  // directory names and the files in each exposed as modules
  two: { f: [Function], e: [Function], d: [Function] },
  three: { i: [Function], h: [Function], g: [Function] },
  one: { c: [Function], b: [Function], a: [Function] } }
  • to-exports: Create exports from a directory of non-javascript or javascript files.
  • export-files: node.js utility for exporting a directory of files as modules.
  • map-files: Return an object for a glob of files. Pass a rename function for the keys, or a parse function for the content, allowing it to be used for readable or require-able files.
  • file-reader: Read a glob of files, dynamically choosing the reader or requiring the files based on the file extension.

Running tests

Install dev dependencies.

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 18, 2015.

Keywords

FAQs

Package last updated on 18 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc