Skip to content

Recursively iterates over a directory and requires all files, returning a nested hash structure of all files

License

Notifications You must be signed in to change notification settings

Radagaisus/node-require-directory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Require Directory

https://nodei.co/npm/node-require-directory.png?downloads=true

Simple. Recursively iterates over a directory and require all files, returning a nested hash structure of all files. Only requires CoffeeScript and JS files.

Hat tip to require-directory. I just needed something simpler.

npm install node-require-directory

build status

assert = require 'assert'
require_directory = require '../index'
example_directory = './test/example'

describe 'require-directory', ->
	# This is the directory structure:
	#   example/
	#     - hello.coffee
	#     - hi.coffee
	#     - nested/
	#       - bleep.coffee
	#       - index.coffee
	#       - triple
	#         - yeah.coffee
	#         - index.coffee
	#
  it 'should work', ->
    dir = require_directory(example_directory)
		assert.equal dir.hello, 'world',
		assert.equal dir.hi, 'you',
		assert.equal dir.nested.bleep, 'boop'
		assert.equal dir.nested.triple.yeah, 'woo'
		assert.equal dir.nested.get, 'bloop'
		assert.equal dir.nested.triple.index, 'hello'
		assert.equal dir.nested.DS_Store, undefined
		assert.equal dir.nested.unknown_weird_file, undefined

About

Recursively iterates over a directory and requires all files, returning a nested hash structure of all files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published