mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-19 11:16:38 +00:00
Document resin/data/fs-utils
This commit is contained in:
parent
608716a692
commit
8c774bace2
@ -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?
|
||||
|
Loading…
Reference in New Issue
Block a user