include-folder
expose the content of each file in a folder as an object property.
Last updated 9 years ago by parroit .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install include-folder 
SYNC missed versions from official npm registry.

include-folder

Build Status Npm module Code Climate

Expose the content of each file in a folder as an object property.

This module is browserifiable using the folderify transform

Getting Started

Install the module with: npm install include-folder --save

Then use like this:

var includeFolder = require('include-folder'),
    folder = includeFolder("./aFolder");

Supposing that the content of aFolder was the same as in the sample in test folder var will contains:

{
    file3OtherFile: 'this is file3OtherContent content',
    file1: 'this is file1 content',
    file1_1: 'this is file1_1 content'
}

Filter included files

You can filter which files to include using the filter parameter:

var includeFolder = require('include-folder'),
    folder = includeFolder("./aFolder",/^a.*/);

This only include files that start with 'a'

Filter parameters defaults to /^[^.].*$/, which include every file in the folder, except hidden ones (these that has a name starting with dot).

Preserve filenames

To prevent normalization and stripping of the extension in the result object, the preserveFilenames option can be used:

includeFolder('./www', null, { preserveFilenames: true });

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

License

Copyright (c) 2013 parroit Licensed under the MIT license.

Current Tags

  • 1.0.0                                ...           latest (9 years ago)

9 Versions

  • 1.0.0                                ...           9 years ago
  • 0.9.0                                ...           10 years ago
  • 0.8.0                                ...           10 years ago
  • 0.7.0                                ...           11 years ago
  • 0.6.0                                ...           11 years ago
  • 0.5.0                                ...           11 years ago
  • 0.4.0                                ...           11 years ago
  • 0.3.0                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (6)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE