From 9574943766266215781b2cc2594611b087347c36 Mon Sep 17 00:00:00 2001 From: Tuomas Salo Date: Thu, 15 Aug 2013 11:05:53 +0300 Subject: [PATCH 1/2] requireDir and requireDirLazy now ignores files and dirs starting with a dot --- lib/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/index.js b/lib/index.js index ac9f925..65a05ec 100644 --- a/lib/index.js +++ b/lib/index.js @@ -359,6 +359,10 @@ utile.requireDir = function (directory) { files = fs.readdirSync(directory); files.forEach(function (file) { + if (file[0] === '.') { + return; + } + if (file.substr(-3) === '.js') { file = file.substr(0, file.length - 3); } @@ -379,6 +383,10 @@ utile.requireDirLazy = function (directory) { files = fs.readdirSync(directory); files.forEach(function (file) { + if (file[0] === '.') { + return; + } + if (file.substr(-3) === '.js') { file = file.substr(0, file.length - 3); } From 2c8ea1ccb935de93bfe5021c201a82ccaa13c664 Mon Sep 17 00:00:00 2001 From: Tuomas Salo Date: Thu, 15 Aug 2013 11:12:23 +0300 Subject: [PATCH 2/2] add dot file and dir to test fixtures --- test/fixtures/require-directory/.dot_directory/.gitignore | 4 ++++ test/fixtures/require-directory/.dot_file.js | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 test/fixtures/require-directory/.dot_directory/.gitignore create mode 100644 test/fixtures/require-directory/.dot_file.js diff --git a/test/fixtures/require-directory/.dot_directory/.gitignore b/test/fixtures/require-directory/.dot_directory/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/test/fixtures/require-directory/.dot_directory/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/test/fixtures/require-directory/.dot_file.js b/test/fixtures/require-directory/.dot_file.js new file mode 100644 index 0000000..c6fb42d --- /dev/null +++ b/test/fixtures/require-directory/.dot_file.js @@ -0,0 +1,2 @@ +exports.me = 'dot_file.js'; +