summaryrefslogtreecommitdiffstats
path: root/lib/utils
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-11-16 10:39:29 +0100
committerSamy Pessé <samypesse@gmail.com>2015-11-16 10:39:29 +0100
commit3a5207a0d2e9450a57c2cae851ddce03a247137f (patch)
treeea363b244c57332ae17aee0141f8f2d4a7fe994a /lib/utils
parent8df6bdca89a0fce90015340d57b3f70292083c42 (diff)
parente38f3bb88423a17a7d0b292d86805a37f72cbff2 (diff)
downloadgitbook-3a5207a0d2e9450a57c2cae851ddce03a247137f.zip
gitbook-3a5207a0d2e9450a57c2cae851ddce03a247137f.tar.gz
gitbook-3a5207a0d2e9450a57c2cae851ddce03a247137f.tar.bz2
Merge pull request #1016 from GitbookIO/fix/999
Fix #999: detection of structure should be case incensitive
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/fs.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/utils/fs.js b/lib/utils/fs.js
index 716e3a0..b82701f 100644
--- a/lib/utils/fs.js
+++ b/lib/utils/fs.js
@@ -30,6 +30,7 @@ var fsUtils = {
fs.exists(path, d.resolve);
return d.promise;
},
+ findFile: findFile,
existsSync: fs.existsSync.bind(fs),
readFileSync: fs.readFileSync.bind(fs),
clean: cleanFolder,
@@ -178,4 +179,15 @@ function cleanFolder(root) {
});
}
+// Find a file in a folder (case incensitive)
+// Return the real filename
+function findFile(root, filename) {
+ return Q.nfcall(fs.readdir, root)
+ .then(function(files) {
+ return _.find(files, function(file) {
+ return (file.toLowerCase() == filename.toLowerCase());
+ });
+ });
+}
+
module.exports = fsUtils;