Document resin/data/fs-utils

This commit is contained in:
Juan Cruz Viotti 2014-12-05 14:39:12 -04:00
parent 608716a692
commit 8c774bace2

View File

@ -1,10 +1,33 @@
fs = require('fs')
_ = require('lodash')
# TODO: There should be more complex checks here
# Check if valid path
#
# @private
#
# @param {String} path path
# @return {Boolean} is valid path
#
# @todo There should be more complex checks here
#
# @example Is valid path?
# console.log isValidPath('/Users/me') # True
# console.log isValidPath([ 1, 2, 3 ]) # False
#
exports.isValidPath = (p) ->
return _.isString(p)
# Check if path is directory
#
# @private
#
# @param {String} directory directory
# @param {Function} callback callback(error, isDirectory)
#
# @example Is directory?
# console.log isDirectory('/usr/local/share') # True
# console.log isDirectory('/Users/me/app.js') # False
#
exports.isDirectory = (directory, callback) ->
fs.stat directory, (error, stats) ->
return callback?(error) if error?